preactjs / wmr

👩‍🚀 The tiny all-in-one development tool for modern web apps.
https://wmr.dev/
MIT License
4.92k stars 109 forks source link

Failed to load wmr.config.ts #914

Closed Aloento closed 1 year ago

Aloento commented 2 years ago

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:

Desktop (please complete the following information):

rschristian commented 2 years ago

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.

developit commented 2 years ago

Do we support .ts for configs?

rschristian commented 2 years ago

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 commented 2 years ago

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