wmr
wmr copied to clipboard
Failed to load wmr.config.ts
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]
wmrorwmr start(development) - [x]
wmr build(production) - [x]
wmr serve
Desktop (please complete the following information):
- OS: Win 11
- Node Version: 17
- WMR Version: newest
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.
Do we support .ts for configs?
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
Going to reopen this as it's a legitimate issue that hasn't yet been fixed.