quasar-ui-qcalendar icon indicating copy to clipboard operation
quasar-ui-qcalendar copied to clipboard

Quasar 2.10.0 vite project ES Module problem

Open mirkofisic opened this issue 3 years ago • 1 comments

Describe the bug I use quasar version 2.10.0 vite, I tried to implement quasar calendar 4.0.0 beta-15 version but when I added the extension and installed the calendar according to the instructions, I get the following error when starting the application.

Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
D:\projects\quasar\swebscansi\node_modules\@quasar\quasar-app-extension-qcalendar\src\boot\register.js:1
import { boot } from 'quasar/wrappers'
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1032:15)
    at Module._compile (node:internal/modules/cjs/loader:1067:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:168:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:195:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:337:24)

I tried to add "type": "module" to package.json, but then I can't start quasar application again because everything is not done as modules:

Running "@quasar/qcalendar" Quasar App Extension...
Error [ERR_REQUIRE_ESM]: require() of ES Module D:\projects\quasar\swebscansi\quasar.config.js from D:\projects\quasar\swebscansi\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 D:\projects\quasar\swebscansi\package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

    at QuasarConfFile.read (D:\projects\quasar\swebscansi\node_modules\@quasar\app-vite\lib\quasar-config-file.js:204:30)
    at goLive (D:\projects\quasar\swebscansi\node_modules\@quasar\app-vite\lib\cmd\dev.js:142:43) {
  code: 'ERR_REQUIRE_ESM'
}

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

To Reproduce Steps to reproduce the behavior:

  1. add extension 'quasar ext add @quasar/qcalendar@next'
  2. install 'npm install @quasar/quasar-ui-qcalendar@next'
  3. run quasar 'quasar dev -m ssr'
  4. See error

Desktop (please complete the following information):

  • OS: [windows]
  • Browser [chrome]
  • Version [10]

mirkofisic avatar Oct 27 '22 10:10 mirkofisic

Same issue here with Quasar v2.11.3 and QCalendar 4.0.0 beta-15. The extension seems not yet compatible with the ssr mode.

websam101 avatar Jan 04 '23 01:01 websam101