-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
quasar.conf - support ESM or .cjs
config files in module projects
#9455
Comments
Here (#6476) there was a previous attempt to support ESM codebases, but I did it when ESM wasn't fully enabled into Node. |
i would also love to see this (
but i imagine it's a lot of work because you would have to rewrite the whole source code. |
This will likely come with the Vite support that @rstoenescu is working on. When creating a new project, you will be asked if you want Webpack or Vite. |
I'd also note that many upsteam projects are forcing the ecosystem by pushing Pure ESM packages Due to this, it may be an idea to skip from Node 12 to Node 16 directly, we should check which are the main differences |
I'm wondering if any more thought has been given to this issue? I'm on Node 16 (LTS) and using Vite per https://quasar.dev/quasar-cli-vite/convert-to-quasar-cli-with-vite. This has been working well for several weeks. I'm happy to be rid of Webpack, Babel, etc. It didn't occur to me to also switch to ESM module resolution until I recently added
I made the same changes to my Quasar project, and although lint is happy, I get the following error when I run
I tried changing the filename to
|
Not yet, even Node 16 have many quirks around ESM support unluckily. |
Thanks for the quick response. Probably it is naive of me to think a quick solution such as the dynamic loader explicitly looking for |
What is the timeline for Quasar 3? This is a big issue for us as we had to struggle with the same issues with tailwind so this was something we were looking to avoid in Quasar. Thank you guys very much for all of your work. |
@clintfoster there are many things to consider, eg a project using native ESM modules from Node (and we use Node in some parts of the framework) must import everything with fully specified path. The Node Loader API is still under heavy development by Node side and experimental We may be able to make it work right now, but the vast majority of the ecosystem isn't ready yet, so it could bring many headaches with little benefit I'll leave here some links I found around, since I bumped my head against this topic again today: |
@jrgleason we planned to start working on it this quarter, but Vue 2.7 release could potentially result in a longer lifecycle for Qv1 and thus postponing Qv3 works, as we don't have enough bandwidth to maintain 3 major version of the framework at the same time Right now we're spending our energies to enhance Qv2 as much as possible instead of planning for Qv3 |
I can't imagine quasar still forces to use commonjs Can be fixed via #15756 |
Quasar CLI packages (both vite and webpack) are currently being rewritten in ESM |
That quick fix in PR above can allow usage of quasar in ESM project if you put config in cjs file. I hope it will be reviewed properly. IMO it's an important issue which can be easily fixed without waiting for quasar 3 or the whole project being rewritten. |
Posting my comment from the PR:
|
* feat: support quasar.conf(ig).cjs #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 :) * Update app-paths.js --------- Co-authored-by: Razvan Stoenescu <razvan.stoenescu@gmail.com>
It looks like it will be quite a while until a release that supports |
Any news regarding the ESM/TS quasar config? I'm using vite 5 and the next major of vite will remove CJS support When building this warning pops up |
The next major version, currently in alpha phase as we finish the upgrade docs, natively supports ESM and TS |
https://github.com/quasarframework/quasar/releases/tag/%40quasar%2Fapp-vite-v2.0.0-beta.1 https://github.com/quasarframework/quasar/releases/tag/%40quasar%2Fapp-webpack-v4.0.0-beta.1 |
@yusufkandemir would it make sense to change the default quasar/app-vite/tsconfig-preset.json Line 6 in 9aa98a8
Also we should set
And according to https://www.typescriptlang.org/tsconfig#moduleResolution our used value |
Is your feature request related to a problem? Please describe.
When people use module type projects, it results in confusing issues like #9454
Describe the solution you'd like
Ideally, it would support loading ESM config files, or maybe even TS
Describe alternatives you've considered
Converting project to classic type, or maybe manually playing around with ts-node or some kind of compilation?
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: