Skip to content
This repository has been archived by the owner on Sep 16, 2023. It is now read-only.

import { type T } from 'non-lodash' #180

Open
ckknight opened this issue Jul 21, 2017 · 7 comments
Open

import { type T } from 'non-lodash' #180

ckknight opened this issue Jul 21, 2017 · 7 comments

Comments

@ckknight
Copy link

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 pkgStores 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.

@jdalton
Copy link
Member

jdalton commented Jul 22, 2017

Hi @ckknight!

Is that typing TypeScript or Flow?

@ckknight
Copy link
Author

ckknight commented Aug 8, 2017

Flow

@dlebedynskyi
Copy link

dlebedynskyi commented Mar 11, 2018

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 babel/babel#7233

@piotrwitek
Copy link

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>;

@sarod
Copy link

sarod commented Jan 25, 2019

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?

@knpwrs
Copy link

knpwrs commented Mar 13, 2019

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.

@phatpt8
Copy link

phatpt8 commented Jun 10, 2019

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

7 participants