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

Webpack 4 issue with babel-loader as post loader #114

Open
ljqx opened this issue Oct 17, 2018 · 1 comment
Open

Webpack 4 issue with babel-loader as post loader #114

ljqx opened this issue Oct 17, 2018 · 1 comment

Comments

@ljqx
Copy link

ljqx commented Oct 17, 2018

Hi, I'm using this loader with babel-loader as post loader of this one.
But it would break for the included .pug files after upgraded to Webpack 4.

The Webpack config I'm using:

rules: {
  { test: /\.pug$/, loader: 'pug-loader' },
  { test: /\.pug$/, loader: 'babel-loader', enforce: 'post' },
}

And the pug code:

//- the included one
mixin sharedMixin()
  .blabla
//- the including one
include ./shared-mixin
+sharedMixin()

The problem behind this is this part of code assumes the loaded content is exactly string, but babel-loader would add "use strict";\n ${theString}; around it. So this part of code cannot parse it anymore.

In Webpack 3, babel-loader is not included as post loader somehow. Though this it seems to be a bug of Webpack 3 instead of feature.

Maybe we can have some more reliable way to load the file content?

If it's OK I can send a PR for this.

@ljqx
Copy link
Author

ljqx commented Oct 17, 2018

Temporally I disable babel-loader as post loader issued from a .pug file.

rules: {
  { test: /\.pug$/, loader: 'pug-loader' },
  { test: /\.pug$/, issuer: /\.((?!pug).)+$/, use: 'babel-loader', enforce: 'post' },
}

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

No branches or pull requests

1 participant