Should error / warn when using import or require
See original GitHub issueThese days there are lots of ways to pull in a lodash function. I would expect each of these to generate errors.
import forEach from 'lodash/forEach'
import whatever from 'lodash/forEach'
import { forEach } from 'lodash'
import { forEach as whatever } from 'lodash'
import forEach from 'lodash.foreach'
import whatever from 'lodash.foreach'
const forEach = require('lodash/forEach')
const whatever = require('lodash/forEach')
const { forEach } = require('lodash')
const { forEach: whatever } = require('lodash')
const forEach = require('lodash.foreach')
const whatever = require('lodash.foreach')
I was surprised that this wasn’t generating errors in my project. Did I miss something?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:10 (9 by maintainers)
Top Results From Across the Web
Warning when trying to require a module which is not installed ...
It seems like this is a common issue in webpack. According to the configuration docs, you can use the flag module: { exprContextCritical: ......
Read more >warnings — Warning control — Python 3.11.1 documentation
Python programmers issue warnings by calling the warn() function defined in this module. (C programmers use PyErr_WarnEx() ; see · Warning messages are...
Read more >Must use import to load ES Module / require() of ES ... - GitHub
I have suddenly started getting the following error: $ npm test > geodesy@2.2.0 test /home/travis/build/chrisveness/geodesy > mocha --exit ...
Read more >Using import and require in the same file - Node JS - YouTube
Found solution here: https://www.kindacode.com/article/node-js-how-to- use - import -and- require -in-the-same-file/
Read more >5.2. Warnings and sanity-checking - downloads for Haskell.org
This warning allows to detect such uses of * before the actual breaking change takes place. The recommended fix is to replace *...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@heygrady Could you send us a PR?
https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore/pull/197 adds support for
require
as well