-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
adapters - generalSupport for functionality general to all adaptersSupport for functionality general to all adapters
Description
Opening this for feedback before I go ahead and add the build step, but it looks like we can't use commonjs in adapters and then depend on esm modules such as @sveltejs/app-utils if we expect anything to work.
This sort of thing:
const { copy } = require('@sveltejs/app-utils/files');relies on the exports map present in @sveltejs/app-utils:
"exports": {
"./files": {
"import": "./files/index.js"
},
"./http": {
"import": "./http/index.js"
}
},However this needs to be modified to allow require to access these exports too:
"exports": {
"./files": {
"import": "./files/index.js",
"require": "./files/index.js"
},
...
},This then causes the following error:
Must use import to load ES Module: /home/ant/Projects/kezia.ws/adapter/node_modules/@sveltejs/app-utils/files/index.js
require() of ES modules is not supported.
require() of /home/ant/Projects/kezia.ws/adapter/node_modules/@sveltejs/app-utils/files/index.js from /home/ant/Projects/kezia.ws/adapter/index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename /home/ant/Projects/kezia.ws/adapter/node_modules/@sveltejs/app-utils/files/index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/ant/Projects/kezia.ws/adapter/node_modules/@sveltejs/app-utils/package.json.
So it looks like we need to build app-utils for cjs and esm in order that it can be used with both types of module.
Happy to go ahead and do this and then fix the vercel and begin adapters accordingly if I'm not missing something.
Metadata
Metadata
Assignees
Labels
adapters - generalSupport for functionality general to all adaptersSupport for functionality general to all adapters