diff --git a/.changeset/metal-clouds-raise.md b/.changeset/metal-clouds-raise.md new file mode 100644 index 0000000000..9693100fb3 --- /dev/null +++ b/.changeset/metal-clouds-raise.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +breaking: move compiler.cjs to compiler/index.js diff --git a/.eslintignore b/.eslintignore index fbab8fbc0d..3b486d3f07 100644 --- a/.eslintignore +++ b/.eslintignore @@ -11,6 +11,7 @@ **/vite.config.js **/vite.prod.config.js **/node_modules +**/compiler/index.js **/tests/** @@ -20,4 +21,4 @@ documentation/** # contains a fork of the REPL which doesn't adhere to eslint rules sites/svelte-5-preview/** # Wasn't checked previously, reenable at some point -sites/svelte.dev/** +sites/svelte.dev/** diff --git a/.prettierignore b/.prettierignore index dc6385309b..558f1fcb85 100644 --- a/.prettierignore +++ b/.prettierignore @@ -13,7 +13,7 @@ packages/svelte/tests/**/shards/*.test.js packages/svelte/tests/hydration/samples/*/_expected.html packages/svelte/tests/hydration/samples/*/_override.html packages/svelte/types -packages/svelte/compiler.cjs +packages/svelte/compiler/index.js playgrounds/demo/src playgrounds/sandbox/input/**.svelte playgrounds/sandbox/output diff --git a/packages/svelte/.gitignore b/packages/svelte/.gitignore index 8b3d7652a1..d0c4ba8d61 100644 --- a/packages/svelte/.gitignore +++ b/packages/svelte/.gitignore @@ -1,6 +1,6 @@ /types/*.map /types/compiler -/compiler.cjs +/compiler/index.js /action.d.ts /animate.d.ts diff --git a/packages/svelte/compiler/package.json b/packages/svelte/compiler/package.json new file mode 100644 index 0000000000..5bbefffbab --- /dev/null +++ b/packages/svelte/compiler/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/svelte/package.json b/packages/svelte/package.json index e71b7c0c68..09e3a00a71 100644 --- a/packages/svelte/package.json +++ b/packages/svelte/package.json @@ -12,7 +12,7 @@ "src", "!src/**/*.test.*", "types", - "compiler.cjs", + "compiler/index.js", "*.d.ts", "README.md" ], @@ -34,7 +34,7 @@ }, "./compiler": { "types": "./types/index.d.ts", - "require": "./compiler.cjs", + "require": "./compiler/index.js", "default": "./src/compiler/index.js" }, "./easing": { diff --git a/packages/svelte/rollup.config.js b/packages/svelte/rollup.config.js index 5a9a220411..3e36190f9c 100644 --- a/packages/svelte/rollup.config.js +++ b/packages/svelte/rollup.config.js @@ -9,7 +9,7 @@ import './scripts/generate-version.js'; export default defineConfig({ input: 'src/compiler/index.js', output: { - file: 'compiler.cjs', + file: 'compiler/index.js', format: 'umd', name: 'svelte' }, diff --git a/sites/svelte-5-preview/src/lib/workers/bundler/index.js b/sites/svelte-5-preview/src/lib/workers/bundler/index.js index bd0ee9d67e..80e14badbf 100644 --- a/sites/svelte-5-preview/src/lib/workers/bundler/index.js +++ b/sites/svelte-5-preview/src/lib/workers/bundler/index.js @@ -48,10 +48,8 @@ self.addEventListener( const { version } = await fetch(`${svelte_url}/package.json`).then((r) => r.json()); console.log(`Using Svelte compiler version ${version}`); - // unpkg doesn't set the correct MIME type for .cjs files - // https://github.com/mjackson/unpkg/issues/355 - const compiler = await fetch(`${svelte_url}/compiler.cjs`).then((r) => r.text()); - (0, eval)(compiler + '\n//# sourceURL=compiler.cjs@' + version); + const compiler = await fetch(`${svelte_url}/compiler/index.js`).then((r) => r.text()); + (0, eval)(compiler + '\n//# sourceURL=compiler/index.js@' + version); svelte = globalThis.svelte; diff --git a/sites/svelte-5-preview/src/lib/workers/compiler/index.js b/sites/svelte-5-preview/src/lib/workers/compiler/index.js index d3d7e475d1..d264e702a0 100644 --- a/sites/svelte-5-preview/src/lib/workers/compiler/index.js +++ b/sites/svelte-5-preview/src/lib/workers/compiler/index.js @@ -29,10 +29,8 @@ self.addEventListener( .then((r) => r.json()) .catch(() => ({ version: 'experimental' })); - // unpkg doesn't set the correct MIME type for .cjs files - // https://github.com/mjackson/unpkg/issues/355 - const compiler = await fetch(`${svelte_url}/compiler.cjs`).then((r) => r.text()); - (0, eval)(compiler + '\n//# sourceURL=compiler.cjs@' + version); + const compiler = await fetch(`${svelte_url}/compiler/index.js`).then((r) => r.text()); + (0, eval)(compiler + '\n//# sourceURL=compiler/index.js@' + version); svelte = globalThis.svelte; diff --git a/sites/svelte-5-preview/src/routes/svelte/[...path]/+server.js b/sites/svelte-5-preview/src/routes/svelte/[...path]/+server.js index d2a35f0727..8ac64dd223 100644 --- a/sites/svelte-5-preview/src/routes/svelte/[...path]/+server.js +++ b/sites/svelte-5-preview/src/routes/svelte/[...path]/+server.js @@ -1,4 +1,4 @@ -import compiler_cjs from '../../../../../../packages/svelte/compiler.cjs?url'; +import compiler_cjs from '../../../../../../packages/svelte/compiler/index.js?url'; import package_json from '../../../../../../packages/svelte/package.json?url'; import { read } from '$app/server'; @@ -14,14 +14,14 @@ export const prerender = true; export function entries() { const entries = Object.keys(files).map((path) => ({ path: path.replace(prefix, '') })); - entries.push({ path: 'compiler.cjs' }, { path: 'package.json' }); + entries.push({ path: 'compiler/index.js' }, { path: 'package.json' }); return entries; } // service worker requests files under this path to load the compiler and runtime export async function GET({ params }) { let url = ''; - if (params.path === 'compiler.cjs') { + if (params.path === 'compiler/index.js') { url = compiler_cjs; } else if (params.path === 'package.json') { url = package_json;