babel-plugin-lodash
babel-plugin-lodash copied to clipboard
import { type T } from 'non-lodash'
Although I can't seem to reproduce this with the lodash
module, it affects others. I suspect that has to do with the differentiation between pkgStore
s where .isLodash()
is used to differentiate.
Using the following .babelrc
{
"plugins": [
["lodash", { "id": ["lodash", "recompose"] }]
],
"presets": [
["env", { "targets": { "node": 6 } }]
]
}
import { type HOC } from 'recompose';
Throws the following error:
SyntaxError: The 'recompose' method `HOC` is not a known module.
A workaround
import type { HOC } from 'recompose';
works as expected, but has the downside of not being able to import functions and types simultaneously.
Hi @ckknight!
Is that typing TypeScript or Flow?
Flow
I have similar issue with babel@^7-beta.40 1.
import type {HOC} from 'recompose';
causes
ERROR in ./src/app/agree/containers/Agree.jsx
Module build failed: TypeError: Cannot read property 'path' of undefined
at .../node_modules/babel-plugin-lodash/lib/index.js:228:47
at arrayEach (....node_modules/lodash/_arrayEach.js:15:9)
with
import { type HOC } from 'recompose';
pp/agree/containers/Agree.jsx: The 'recompose' method `HOC` is not a known module.
Please report bugs to https://github.com/lodash/babel-plugin-lodash/issues.
basic babelrc config to reproduce
const presets = [
// bread and butter
[
require('@babel/preset-env').default,
{
shippedProposals: true,
loose: true,
useBuiltIns: 'entry',
...(rest || {}),
modules:
rest.modules ||
(target === 'web' || target === 'client' ? false : 'commonjs'),
},
],
require('@babel/preset-react').default,
// flow since no longer in react
// react
require('@babel/preset-flow').default,
];
const plugins = [
[
"babel-plugin-lodash",
{
id: [
"lodash",
"recompose",
]
}
];
module.exports = { presets, plugins };
I believe this issue may be related https://github.com/babel/babel/issues/7233
I have related issue with TypeScript:
import { Dictionary } from 'lodash';
type ColumnIndexes = Dictionary<number>;
ERROR in ./node_modules/@ihme/common/utility/data/index.ts
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: /Users/piotrek/Make/ihme-gilead/node_modules/@ihme/common/utility/data/index.ts: The 'lodash' method `Dictionary` is not a known module.
Please report bugs to https://github.com/lodash/babel-plugin-lodash/issues.
...
> 13 | type ColumnIndexes = Dictionary<number>;
I have a similar issue with typescript and
import { Cancelable } from 'lodash';
Is there a way to configure a set of modules for which errors should be ignored?
For anyone searching for a workaround I'm currently using this plugin: https://www.npmjs.com/package/babel-plugin-transform-imports
I'm able to import { Dictionary } from 'lodash'
with no errors.
I have related issue with TypeScript:
import { Dictionary } from 'lodash'; type ColumnIndexes = Dictionary<number>;
ERROR in ./node_modules/@ihme/common/utility/data/index.ts Module build failed (from ./node_modules/babel-loader/lib/index.js): SyntaxError: /Users/piotrek/Make/ihme-gilead/node_modules/@ihme/common/utility/data/index.ts: The 'lodash' method `Dictionary` is not a known module. Please report bugs to https://github.com/lodash/babel-plugin-lodash/issues. ... > 13 | type ColumnIndexes = Dictionary<number>;
Hi, I appreciate if anyone tells me this issue status. Is it solved?