Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,8 @@ module.exports = class SingleSpaSvelteGenerator extends PnpmGenerator {
projectName: this.options.projectName,
});
this.fs.copyTpl(
this.templatePath(`jest.config.js`),
this.destinationPath(`jest.config.js`),
this.options
);
this.fs.copyTpl(
this.templatePath(`babel.config.js`),
this.destinationPath(`babel.config.js`),
this.templatePath(`vite.config.mjs`),
this.destinationPath(`vite.config.mjs`),
this.options
);
this.fs.copyTpl(
Expand Down
12 changes: 0 additions & 12 deletions packages/generator-single-spa/src/svelte/templates/babel.config.js

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@ import svelte from "rollup-plugin-svelte";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import livereload from "rollup-plugin-livereload";
import { terser } from "rollup-plugin-terser";
import { minify } from "rollup-plugin-esbuild-minify";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the switch from terser to esbuild? Execution time?

@mac89 mac89 Jul 14, 2025

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was no longer maintained. So it seemed prudent to replace it.
Also it required an outdated version of rollup.

import { spawn } from "child_process";

const production = !process.env.ROLLUP_WATCH;

export default {
input: "src/<%= orgName %>-<%= projectName %>.js",
output: {
sourcemap: true,
format: "system",
format: "esm",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change, and should be reflected in changesets.

name: null, // ensure anonymous System.register
file: "dist/<%= orgName %>-<%= projectName %>.js",
},
plugins: [
svelte({
// enable run-time checks when not in production
dev: !production,
compilerOptions: {
// enable run-time checks when not in production
dev: !production,
},

emitCss: false,
}),
Expand All @@ -43,7 +46,7 @@ export default {

// If we're building for production (npm run build
// instead of npm run dev), minify
production && terser(),
production && minify(),
],
watch: {
clearScreen: false,
Expand All @@ -58,7 +61,7 @@ function serve() {
if (!started) {
started = true;

require("child_process").spawn("npm", ["run", "serve", "--", "--dev"], {
spawn("npm", ["run", "serve", "--", "--dev"], {
stdio: ["ignore", "inherit", "inherit"],
shell: true,
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "@testing-library/jest-dom/vitest";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty weird that @testing-library/jest-dom includes an implementation for vitest, since jest and vitest are competitor libraries.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
export let name;
<script lang="ts">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For create-single-spa's react implementation, typescript is an option passed to the generator, with EJS template for adding typescript syntax. We should add the same for svelte.

let { name } = $props();
</script>

<style>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
{
"name": "<%= name %>",
"type": "module",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change and should be described in a changeset.

"scripts": {
"build": "concurrently <%- packageManager %>:build:*",
"build:rollup": "rollup -c",
"start": "rollup -c -w",
"serve": "sirv dist -c",
"test": "jest",
"test": "vitest",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the jest configuration no longer work after the upgrade to svelte? Why switch from jest to vitest?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To simplify the test setup. Jest requires some hurdles to go through with ESM.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok switching to vitest for this generator. Jest typescript esm with node flags for vm modules is a pain.

"prepare": "husky install",
"format": "prettier --write --plugin-search-dir=. .",
"check-format": "prettier --plugin-search-dir=. --check ."
},
"devDependencies": {
"@babel/core": "^7.23.3",
"@babel/preset-env": "^7.23.3",
"@rollup/plugin-commonjs": "^20.0.0",
"@rollup/plugin-node-resolve": "^13.0.4",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/svelte": "^3.0.3",
"babel-jest": "^27.5.1",
"concurrently": "^6.2.1",
"jest": "^27.5.1",
"prettier": "^2.3.2",
"prettier-plugin-svelte": "^2.3.1",
"rollup": "^2.56.3",
"@babel/core": "^7.27.7",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The babel.config.js was deleted - was it only being used by jest? If so, are @babel/core and @babel/preset-env being used anymore?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I forgot to remove them. Will do so.

"@babel/preset-env": "^7.27.2",
"@rollup/plugin-commonjs": "^28.0.6",
"@rollup/plugin-node-resolve": "^16.0.1",
"@sveltejs/vite-plugin-svelte": "^5.1.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/svelte": "^5.2.8",
"concurrently": "^9.2.0",
"prettier": "^3.6.2",
"prettier-plugin-svelte": "^3.4.0",
"rollup": "^4.44.1",
"rollup-plugin-esbuild-minify": "^1.3.0",
"rollup-plugin-livereload": "^2.0.5",
"rollup-plugin-svelte": "^7.1.0",
"rollup-plugin-terser": "^7.0.2",
"svelte": "^3.42.3",
"svelte-jester": "^2.0.0"
"rollup-plugin-svelte": "^7.2.2",
"svelte": "^5.34.9",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be moved to dependencies

"vitest": "^3.2.4"
},
"dependencies": {
"single-spa-svelte": "^2.1.1",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this version of single-spa-svelte work with svelte@5?

svelte should be moved to dependencies.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"single-spa-svelte": "^2.1.1",
"single-spa-svelte": "^3.0.0-beta.0",

Expand Down
17 changes: 17 additions & 0 deletions packages/generator-single-spa/src/svelte/templates/vite.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { defineConfig } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";

// https://vitejs.dev/config/
export default defineConfig({
plugins: [svelte()],
test: {
globals: true,
environment: "jsdom",
setupFiles: ["./setupTests.js"],
},
resolve: process.env.VITEST
? {
conditions: ["browser"],
}
: undefined,
});