wmr icon indicating copy to clipboard operation
wmr copied to clipboard

Failed to load wmr.config.ts

Open Aloento opened this issue 3 years ago • 4 comments

Describe the bug yarn create wmr
rename wmr.config.mjs to wmr.config.ts then:

Error: Failed to load wmr.config.ts
Error [ERR_REQUIRE_ESM]: require() of ES Module .\node_modules\wmr\index.js from .\wmr.config.js not supported.
Instead change the require of index.js in .\wmr.config.js to a dynamic import() which is available in all CommonJS modules.
TypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string. Received an instance of URL

Bug occurs with:

  • [x] wmr or wmr start (development)
  • [x] wmr build (production)
  • [x] wmr serve

Desktop (please complete the following information):

  • OS: Win 11
  • Node Version: 17
  • WMR Version: newest

Aloento avatar Apr 10 '22 22:04 Aloento

You could add "type": "module" to your package.json if you want to use a TS config at the moment.

We could ship a CJS version of the DefineConfig to fix this. Should be fine to do I imagine.

rschristian avatar Apr 10 '22 23:04 rschristian

Do we support .ts for configs?

developit avatar Apr 10 '22 23:04 developit

Yes, we do. It can end up transpiled to CJS though, which results in that require():

https://github.com/preactjs/wmr/blob/caf7ff840363351b0f52eabf1eff91c3e9888c04/packages/wmr/src/lib/normalize-options.js#L106-L116

rschristian avatar Apr 10 '22 23:04 rschristian

Going to reopen this as it's a legitimate issue that hasn't yet been fixed.

rschristian avatar Apr 11 '22 15:04 rschristian