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: support quasar.conf(ig).cjs #15756

Merged
merged 2 commits into from Apr 29, 2023
Merged

feat: support quasar.conf(ig).cjs #15756

merged 2 commits into from Apr 29, 2023

Conversation

ZerdoX-x
Copy link
Contributor

#9455 I would like to use Quasar with "type": "module" in my package.json.

Without converting file to cjs I get an error from Node:

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/zerdox/p/cryp/table-cups/quasar.config.js from /Users/zerdox/p/cryp/table-cups/node_modules/@quasar/app-vite/lib/quasar-config-file.js not supported.
quasar.config.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead rename quasar.config.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /Users/zerdox/p/cryp/table-cups/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

    at QuasarConfFile.read (/Users/zerdox/p/cryp/table-cups/node_modules/@quasar/app-vite/lib/quasar-config-file.js:204:30)
    at build (/Users/zerdox/p/cryp/table-cups/node_modules/@quasar/app-vite/lib/cmd/build.js:134:43) {
  code: 'ERR_REQUIRE_ESM'
}

 App • ⚠️   FAIL  quasar.config.js has JS errors

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Documentation
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:
    Please let people stick with ESM :)

Does this PR introduce a breaking change?

  • Yes
  • No

The PR fulfills these requirements:

  • It's submitted to the dev branch (or v[X] branch)
  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix: #xxx[,#xxx], where "xxx" is the issue number)
  • It's been tested on a Cordova (iOS, Android) app
  • It's been tested on an Electron app
  • Any necessary documentation has been added or updated in the docs or explained in the PR's description.

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to start a new feature discussion first and wait for approval before working on it)

Other information:
Not supporting ESM is a bug obv

#9455
I would like to use Quasar with `"type": "module"` in my `package.json`.

Without converting file to `cjs` I get an error from Node:
```
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/zerdox/p/cryp/table-cups/quasar.config.js from /Users/zerdox/p/cryp/table-cups/node_modules/@quasar/app-vite/lib/quasar-config-file.js not supported.
quasar.config.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead rename quasar.config.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /Users/zerdox/p/cryp/table-cups/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

    at QuasarConfFile.read (/Users/zerdox/p/cryp/table-cups/node_modules/@quasar/app-vite/lib/quasar-config-file.js:204:30)
    at build (/Users/zerdox/p/cryp/table-cups/node_modules/@quasar/app-vite/lib/cmd/build.js:134:43) {
  code: 'ERR_REQUIRE_ESM'
}

 App • ⚠️   FAIL  quasar.config.js has JS errors
```

Please let me stick with ESM :)
@rstoenescu
Copy link
Member

Hi,

This has already been worked on for next q/app major versions (which will also support everything in ESM format, including the quasar config file).

However, adding this to the current q/apps will be nice as well. BUT, I need to release the new global Quasar CLI first, otherwise commands through it will still fail to recognize the folder as being a Quasar project.

So you will need to be a little patient until I can release the new q/cli.

@rstoenescu rstoenescu self-requested a review April 27, 2023 12:29
@ZerdoX-x
Copy link
Contributor Author

Yeah. I stumbled upon this issue when I found out that my docker was running CLI directly. I just changed it to running to npm run build and ofc applied my patch with patch-package. Thank you for the pretty fast response. Would like to see it merged!

Good luck with a major release 👍

UPD: I also am not sure about webpack. Does it need changes too? I don't use it so I didn't provide any changes for webpack users

@rstoenescu rstoenescu merged commit 6933bcc into quasarframework:dev Apr 29, 2023
@rstoenescu
Copy link
Member

Merged it, but will add more commits to it otherwise it will break some Quasar modes due to project's "type": "module" (which was never supported).

@rstoenescu
Copy link
Member

Out of curiosity, why do you need type: module? Because Electron and SSR do not support it (only SSR with Vite will).

rstoenescu added a commit that referenced this pull request Apr 29, 2023
…ss/babel/eslint config files; normalize create-quasar config files #15756
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.

None yet

2 participants