Git Product home page Git Product logo

Comments (5)

thgreasi avatar thgreasi commented on June 13, 2024

Actually only string liberals are currently supported as an argument at the
moment. Variables #4, string concatenation expressions and template
liberals are not supported. That's because CommonJS bundlers, most namely
webpack and browserify, analyze the code and require a string literal to be
used, so that they can determine the imported modules during the
compilation step (at least that was how things worked when I implemented
this).

Which bundling system are you using?
If this CommonJS limition doesn't exist any more then we should try adding
support for this. At the moment we should be able to add support for this
for AMD and Global transformation targets.

Thodoris Greasidis

from babel-plugin-system-import-transformer.

bernardmcmanus avatar bernardmcmanus commented on June 13, 2024

@thgreasi I'm transpiling to CommonJS. As a workaround I'm just resolving a promise with a require call, which seems to be working just fine:

Bluebird.resolve(require(`./pages/${name}/route`))

I'm using [email protected] so I'm not sure if this is supported in webpack 1, but it recognizes that I'm requiring based on an expression and is using a regex to resolve those imports:

 [268] ./app/pages ^\.\/.*\/route$ 239 bytes {0} [built]
    + 645 hidden modules

from babel-plugin-system-import-transformer.

thgreasi avatar thgreasi commented on June 13, 2024

Thanks for the details. I will check it out as soon as I find some time.
Expressions were not supported back in webpack 1 so I never bothered. Of
course this isn't going to be working for browserify users, which as far as

I know need string literals as require parameters.

Thodoris Greasidis

from babel-plugin-system-import-transformer.

thgreasi avatar thgreasi commented on June 13, 2024

Just released v2.4.0 that should try to transform any expression.
Until now we checked if it was an actual string literal.
Of course the result might not work on all environments, but your webpack2 use case should now work.
Have fun (hopefully) and please, please, please, report back whether it worked for you.

from babel-plugin-system-import-transformer.

bernardmcmanus avatar bernardmcmanus commented on June 13, 2024

@thgreasi awesome thanks! It's working swimmingly 👍

from babel-plugin-system-import-transformer.

Related Issues (14)

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.