Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

give module id an invalid name to prevent invalid replacement #3546

Merged
merged 4 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gorgeous-carrots-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-netlify': patch
---

Fix string replacement in CJS builds
2 changes: 1 addition & 1 deletion packages/adapter-netlify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function ({ split = false } = {}) {
const redirects = [];

const replace = {
APP: './server/app.js'
'0APP': './server/app.js' // digit prefix prevents CJS build from using this as a variable name, which would also get replaced
};

if (esm) {
Expand Down
3 changes: 2 additions & 1 deletion packages/adapter-netlify/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default [
}
],
plugins: [nodeResolve(), commonjs(), json()],
external: ['APP', ...require('module').builtinModules]
external: (id) => id === '0APP' || id.startsWith('node:'),
preserveEntrySignatures: true
}
];
2 changes: 1 addition & 1 deletion packages/adapter-netlify/src/handler.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
declare module 'APP' {
declare module '0APP' {
export { App } from '@sveltejs/kit';
}
2 changes: 1 addition & 1 deletion packages/adapter-netlify/src/handler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import './shims';
import { App } from 'APP';
import { App } from '0APP';

/**
* @param {import('@sveltejs/kit').SSRManifest} manifest
Expand Down