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

vue.config.js esm support #4477

Closed
patarapolw opened this issue Aug 21, 2019 · 5 comments · Fixed by #6405
Closed

vue.config.js esm support #4477

patarapolw opened this issue Aug 21, 2019 · 5 comments · Fixed by #6405

Comments

@patarapolw
Copy link

What problem does this feature solve?

Instead of

require = require("esm")(module);
const { pugFilters } = require("./src/plugins/render");

I can do import { .pugFilter } from "./src/plugins/render" directly.

Note that I have to do ES6 import from source to enable import in other places in TypeScript.

This is to be on par with Webpack Node API

What does the proposed API look like?

// vue.config.js
import { .pugFilter } from "./src/plugins/render";
@haoqunjiang
Copy link
Member

haoqunjiang commented Aug 22, 2019

There are two possible outcomes for this issue:

  1. For support of a custom module format without changing the file extension, we'd preload a module loader before requiring the config file. We may implement a CLI option for this feature, like the config-register option in webpack-cli.
  2. For support of a custom module format with a custom file extension, we can use the interpret package.

@corydorning53
Copy link

is there plans to allow this now that node v14+ allows esm?

@gmichaeljaison
Copy link

Is this released yet? Which version of vue-cli supports this?

@kid1412621
Copy link

Is this released yet? Which version of vue-cli supports this?

I managed to change filename to vue.config.mjs to use esm. It could work. But somehow the settings about css in the file doesn't take effect.

@JinPengGeng
Copy link

is there any update for esm support ??

undergroundwires added a commit to undergroundwires/privacy.sexy that referenced this issue Aug 17, 2023
Configure project to use ES6 modules to enable top-level await
capabilities. This change helps project to align well with modern JS
standards.

- Set `type` to `module` in `package.json`.
- Use import/export syntax in Cypress configuration files.
- Rename configurations files that do not support modules to use
  the `.cjs` extension:
  - `vue.config.js` to `vue.config.cjs` (vuejs/vue-cli#4477).
  - `babel.config.js` to `babel.config.cjs (babel/babel-loader#894)
  - `.eslintrc.js` to `.eslintrc.cjs` (eslint/eslint#13440,
    eslint/eslint#14137)
  - `postcss.config.js` to `postcss.config.cjs` (postcss/postcss#1771)
undergroundwires added a commit to undergroundwires/privacy.sexy that referenced this issue Aug 17, 2023
Configure project to use ES6 modules to enable top-level await
capabilities. This change helps project to align well with modern JS
standards.

- Set `type` to `module` in `package.json`.
- Use import/export syntax in Cypress configuration files.
- Rename configurations files that do not support modules to use
  the `.cjs` extension:
  - `vue.config.js` to `vue.config.cjs` (vuejs/vue-cli#4477).
  - `babel.config.js` to `babel.config.cjs (babel/babel-loader#894)
  - `.eslintrc.js` to `.eslintrc.cjs` (eslint/eslint#13440,
    eslint/eslint#14137)
  - `postcss.config.js` to `postcss.config.cjs` (postcss/postcss#1771)
- Provide a workaround for Vue CLI & Mocha ES6 modules conflict in
  Vue configuration file (vuejs#7417).
undergroundwires added a commit to undergroundwires/privacy.sexy that referenced this issue Aug 17, 2023
Configure project to use ES6 modules to enable top-level await
capabilities. This change helps project to align well with modern JS
standards.

- Set `type` to `module` in `package.json`.
- Use import/export syntax in Cypress configuration files.
- Rename configurations files that do not support modules to use
  the `.cjs` extension:
  - `vue.config.js` to `vue.config.cjs` (vuejs/vue-cli#4477).
  - `babel.config.js` to `babel.config.cjs (babel/babel-loader#894)
  - `.eslintrc.js` to `.eslintrc.cjs` (eslint/eslint#13440,
    eslint/eslint#14137)
  - `postcss.config.js` to `postcss.config.cjs` (postcss/postcss#1771)
- Provide a workaround for Vue CLI & Mocha ES6 modules conflict in
  Vue configuration file (vuejs/vue-cli#7417).
LarrMarburger added a commit to LarrMarburger/privacy.sexy that referenced this issue Nov 16, 2023
Configure project to use ES6 modules to enable top-level await
capabilities. This change helps project to align well with modern JS
standards.

- Set `type` to `module` in `package.json`.
- Use import/export syntax in Cypress configuration files.
- Rename configurations files that do not support modules to use
  the `.cjs` extension:
  - `vue.config.js` to `vue.config.cjs` (vuejs/vue-cli#4477).
  - `babel.config.js` to `babel.config.cjs (babel/babel-loader#894)
  - `.eslintrc.js` to `.eslintrc.cjs` (eslint/eslint#13440,
    eslint/eslint#14137)
  - `postcss.config.js` to `postcss.config.cjs` (postcss/postcss#1771)
- Provide a workaround for Vue CLI & Mocha ES6 modules conflict in
  Vue configuration file (vuejs/vue-cli#7417).
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.

6 participants