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

feat: Add compilerFile for options #1533

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vincenting
Copy link

For some reasons, we alway get a error when building in production mode: compiler.parseComponent is not a function.

After we tried to debug it, we found some loaders call vue-loader with stringified args, which resulting in losing all functions we declared in our config. (VueTemplateCompiler)

Here is another similar issue #1454

The easiest way to fix it is using a string param to pass the configuration of compiler. So, use a compilerFile: string will be a choose for this case.

{
  compilerFile: 'absPathToCompilerFile',
} 

@vincenting
Copy link
Author

vincenting commented Apr 8, 2019

https://cli.vuejs.org/config/#parallel
https://github.com/webpack-contrib/terser-webpack-plugin#parallel

In production mode (vue-cli-service), parallel is enabled by default, which as a result leading to this issue. We are now disable parallel to avoid this error in production.

vue-loader is now using loader-utils#getOptions to parse params. Which means all the data structure supported by JSON is suggested as options. VueTemplateCompiler is a kind of data structure with Function, which will leave some risks in some certain conditions.

@viruscamp
Copy link

viruscamp commented Sep 17, 2019

  1. It's better to use the same option name.
    compiler: String | VueTemplateCompiler
  2. Other loader-options that cannot be stringified , should be treat the same way. Just like:
{
  compiler:  String | VueTemplateCompiler
  compilerOptions: {
    modules: Array<string | ModuleOptions>,
    directives: { [key: string]: String | Function }
  }
}

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

Successfully merging this pull request may close these issues.

3 participants