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

Support "type" field in package.json for ES Modules #5046

Closed
Worthaboutapig opened this issue Jan 7, 2020 · 1 comment · Fixed by #5293
Closed

Support "type" field in package.json for ES Modules #5046

Worthaboutapig opened this issue Jan 7, 2020 · 1 comment · Fixed by #5293

Comments

@Worthaboutapig
Copy link

What problem does this feature solve?

Currently the vue.config.js must be named exactly that, as far as I can see.

I'm using the "type": "moduel" key in package.json, as I'm using the --experimental-modules feature of Nodejs. However, as vue.config.js is not an ES module, an error is thrown and nothing works.

The suggested solution is to rename the file vue.config.cjs, then node accepts the file is in CJS format and it's happy. This change has been implemented in other tools, and, although technically still experimental, it's not likely to be for long. It's already been out from under a flag once, but had to go back because of a lack of ES Lint support (that's been resolved).

It would be helpful, and presumably wouldn't have an impact elsewhere to accept a file called vue.config.cjs, which is functionally and formatted identically (simply accept a second file name with a different extension).

Additionally, presumably this will have to be done eventually, unless Vue intends never to support ES modules, which wouldn't be helpful.

I'm happy to write up a PR, if someone can point me in the direction of where to look...

What does the proposed API look like?

The config file can be called either vue.config.js or vue.config.cjs. They would be identical, other than the extension.

@simon300000
Copy link
Contributor

simon300000 commented Mar 19, 2020

I made a pr #5293 which could solve this issue,

But I believe using await import(configPath) will be a better solution, which supports both commonjs and module;
however this will make the whole process asynchronous, maybe this will be the Future after something like #4954 is somehow resolved.

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

Successfully merging a pull request may close this issue.

3 participants