Giter Club home page Giter Club logo

Comments (9)

ljharb avatar ljharb commented on May 18, 2024 3

@wmm387 @KnisterPeter this plugin is for node, not for webpack - we have https://github.com/airbnb/babel-plugin-dynamic-import-webpack for webpack 1 and 2, and webpack 3+ understands this syntax natively.

from babel-plugin-dynamic-import-node.

haiweilian avatar haiweilian commented on May 18, 2024

I also have this problem.

from babel-plugin-dynamic-import-node.

imzyxwvu avatar imzyxwvu commented on May 18, 2024

Me too. Downgrading fixes this.

from babel-plugin-dynamic-import-node.

CiklopLT avatar CiklopLT commented on May 18, 2024

Same here, should be downgraded to 2.3.0

from babel-plugin-dynamic-import-node.

KnisterPeter avatar KnisterPeter commented on May 18, 2024

The created output here is something like this:

Promise.resolve('prefix-${var}').then(s => require(s))

If this is check by webpack, it results in unmatched dynamic imports.
Webpack could understand require('prefix-${var}') but not require(s)

The fix for #84 need to be reverted and fixed in another way.

from babel-plugin-dynamic-import-node.

ljharb avatar ljharb commented on May 18, 2024

cc @nicolo-ribaudo we may have to revert to the original, but still evaluate the result twice so as to evaluate it sync?

from babel-plugin-dynamic-import-node.

KnisterPeter avatar KnisterPeter commented on May 18, 2024

@ljharb Thanks for the hint

from babel-plugin-dynamic-import-node.

nicolo-ribaudo avatar nicolo-ribaudo commented on May 18, 2024

cc @nicolo-ribaudo we may have to revert to the original, but still evaluate the result twice so as to evaluate it sync?

Evaluating twice is worse than evaluating asynchronously. Also, it would bring back the bug that originally led to that PR (yield or await inside import arguments).

If the dynamic import argument is a single StringLiteral, we could transpile it to

Promise.resolve().then(s => require("./module"))

in more complex cases where it would be observable, I think that it is better to do the correct thing rather than trying to adapt the output to webpack, which doesn't need this plugin in the first place.

from babel-plugin-dynamic-import-node.

ljharb avatar ljharb commented on May 18, 2024

That seems totally reasonable.

from babel-plugin-dynamic-import-node.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.