-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adapter-vercel: Use CJS entrypoint to load ESM files (#483)
* adapter-vercel fixes Replace require() with await import() Replace url.parse with new URL() * adapter-vercel changeset * adapter-vercel: actually use existing headers * adapter-vercel: Use single CJS entrypoint * adapter-vercel: rename app.js to app.mjs * adapter-vercel: Don't fail on mkdirSync * adapter-vercel: fix deconstruct
- Loading branch information
Showing
5 changed files
with
41 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sveltejs/adapter-vercel': patch | ||
--- | ||
|
||
Fix mixed usage of CJS and ESM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
import { nodeResolve } from '@rollup/plugin-node-resolve'; | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
|
||
export default { | ||
input: 'src/index.js', | ||
output: { | ||
file: 'files/index.js', | ||
format: 'esm', | ||
sourcemap: true, | ||
exports: 'default' | ||
export default [ | ||
{ | ||
input: 'src/entry.js', | ||
output: { | ||
file: 'files/entry.mjs', | ||
format: 'es', | ||
sourcemap: true, | ||
exports: 'default' | ||
}, | ||
plugins: [nodeResolve(), commonjs()], | ||
external: [...require('module').builtinModules, './server/app.mjs'] | ||
}, | ||
plugins: [nodeResolve(), commonjs()], | ||
external: require('module').builtinModules | ||
}; | ||
{ | ||
input: 'src/index.cjs', | ||
output: { | ||
file: 'files/index.js' | ||
}, | ||
external: './entry.mjs' | ||
} | ||
]; |
11 changes: 6 additions & 5 deletions
11
packages/adapter-vercel/src/index.js → packages/adapter-vercel/src/entry.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = async (res, req) => { | ||
const { default: app } = await import('./entry.mjs'); | ||
await app(res, req); | ||
}; |