Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rudimentary ES2015 module transpilation #26

Closed
wants to merge 1 commit into from

Conversation

benurb
Copy link
Contributor

@benurb benurb commented Jul 28, 2017

The better approach is to run babel-loader before extract-loader, but this "transpilation" at least enables file-loader 1.0.0 to integrate without syntax errors.

The better approach is to run babel-loader before extract-loader
@benurb benurb requested a review from jhnns July 28, 2017 13:39
@coveralls
Copy link

coveralls commented Jul 28, 2017

Coverage Status

Coverage increased (+0.07%) to 98.113% when pulling 2a53945 on fix/es2015-module-run into dd1c106 on master.

// "Transpile" imports
src = src.replace(/^import\s+(.+)\s+from\s+([^;]+);?$/, "var $1 = require($2);");
// "Transpile" default export (other exports are not supported at the moment)
src = src.replace(/^\s*export\s+default\s*/, "module.exports = ");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should do that. Replacing strings in the source code is imho too risky and can introduce strange bugs (from the user's perspective). Why not using babel? When there are no plugins, transpiling should be really cheap.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree in general. On the other hand it might not be clear to users of extract-loader, that you need babel in order to use file-loader 1.0.0+. Imho we should at least document that problem in the readme or make the "transpilation" in this PR more specific to the file-loader. What do you think?

@jhnns
Copy link
Member

jhnns commented Jan 12, 2018

Just for the record: the file-loader reverted ESM support 3 months ago because of issues in the css-loader. Closing this for now because I think that we should not use that approach. Maybe node's ESM support will come right in time :)

Anyway, thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants