-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
Module parse failed: Unexpected token (1:0) when combined with html-webpack-plugin #322
Comments
Before creating the minimal reproduction sample, I tried to debug the compilation problem using the method documented at https://indepth.dev/posts/1166/this-will-make-you-more-efficient-at-debugging-webpack-unspecified-build-errors This led to finding out that the error message source is from the index.html data being passed to a JavascriptParser: In the above screenshot you can see the 'this.parser' value (JavascriptParser) and 'source' value (the index.html contents). I did not manage to discover how that JavascriptParser ended up being used. |
I noticed that this issue would probably better fit under https://github.com/intlify/bundle-tools/ . If so, would it be possible to transfer this issue there? |
The rules don't seems right :
it seams the loader will process every single file |
Where did you find these rules? The rules block in the reproduction sample is empty, so is this a result generated by some later processing step? |
By debugging the webpack run to check the rules, I noticed that in node_modules/unplugin/dist/index.js there is:
Here the I tested modifying the |
Even with a workaround in place, the @intlify/unplugin-vue-i18n seemed to interfere with source maps next. I ended up moving the @intlify/unplugin-vue-i18n usage to a separate project that has no other plugins defined. This project only compiles the locale data to precompiled messages. The result of this workaround project is then read in the main project and provided via the Overall, to me it seems that @intlify/unplugin-vue-i18n attaches a bit too heavily into the Webpack build process and causes side effects in places it would not be expected to affect. When used in a separate project, it works fine. |
i used https://www.npmjs.com/package/webpack-config-dump-plugin to dump the config, it's the rules added by the unplugin-vue-18n, i did not found where in the source code, i only found the https://stackblitz.com/edit/htmlplugin-t3ibcm-fxv235?file=webpack.config.dump the html rules, i added it myself, but it did not solve anything |
Thank you for reporting! |
+1 |
I have the same problem. Does anyone have a workaround or a bug fix for this? |
+1 |
I got this working by doing separate webpack plugin that is triggered from main webpack. This ouputs translations to file that is used as precompiled messages. This is VERY HACKY SOLUTION, use with your own risk CustomPlugin
In your main webpack import and add this plugin to ../src/translations/compile.js
Changes to your main webpack createI18n
|
First time testdriving and hit this issue with html-loader. |
I have the same issue. However, it seems it only occurs using |
@kazupon since you seem to be active in development, can you look into this? |
Reporting a bug?
When using webpack with both html-webpack-plugin and @intlify/unplugin-vue-i18n, the compilation fails with:
The @intlify/unplugin-vue-i18n for some reason ends up as an additional loader for index.html, even though it is not being configured so. Omitting either plugin makes the compilation pass, so this seems to be a strange interaction between the plugins.
Expected behavior
I'd assume there should be no errors.
Reproduction
Please see https://stackblitz.com/edit/htmlplugin-t3ibcm
It should start building automatically and display the error in both terminal and the right hand side. If it does not start automatically, use in the terminal:
npm install && npm start
System Info
Screenshot
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: