diff --git a/packages/viewer/package.json b/packages/viewer/package.json index 7044680e..5238e9cc 100644 --- a/packages/viewer/package.json +++ b/packages/viewer/package.json @@ -4,10 +4,10 @@ "version": "1.0.0", "license": "ISC", "scripts": { - "build": "rollup -c", + "build": "rollup --config rollup.config.mts --configPlugin @rollup/plugin-typescript", "cy:open": "cypress open", "cy:run": "cypress run", - "dev": "rollup -c -w", + "dev": "rollup --config rollup.config.mts --configPlugin @rollup/plugin-typescript --watch", "start": "sirv public --single", "test": "vitest", "test:cov": "vitest --coverage", @@ -33,21 +33,22 @@ "unist-util-visit": "^4.1.2" }, "devDependencies": { - "@rollup/plugin-commonjs": "^24.0.1", + "@rollup/plugin-commonjs": "^24.1.0", "@rollup/plugin-json": "^6.0.0", - "@rollup/plugin-node-resolve": "^15.0.1", + "@rollup/plugin-node-resolve": "^15.0.2", "@rollup/plugin-replace": "^5.0.2", - "@rollup/plugin-typescript": "^11.0.0", + "@rollup/plugin-typescript": "^11.1.0", "@tsconfig/svelte": "^3.0.0", "@types/hyperscript": "0.0.4", "@types/katex": "^0.16.0", "@types/page": "^1.8.0", + "@types/rollup-plugin-css-only": "^3.1.0", "@types/unist": "^2.0.3", "cypress": "^12.7.0", - "rollup": "^3.18.0", - "rollup-plugin-copy": "^3.3.0", + "rollup": "^3.21.5", + "rollup-plugin-copy": "^3.4.0", "rollup-plugin-css-only": "^4.3.0", - "rollup-plugin-livereload": "^2.0.0", + "rollup-plugin-livereload": "^2.0.5", "rollup-plugin-node-globals": "^1.4.0", "rollup-plugin-node-polyfills": "^0.2.1", "rollup-plugin-svelte": "^7.1.4", diff --git a/packages/viewer/rollup.config.mjs b/packages/viewer/rollup.config.mts similarity index 72% rename from packages/viewer/rollup.config.mjs rename to packages/viewer/rollup.config.mts index db3262b9..2a139537 100644 --- a/packages/viewer/rollup.config.mjs +++ b/packages/viewer/rollup.config.mts @@ -1,32 +1,31 @@ +import type { RollupOptions } from 'rollup'; import svelte from 'rollup-plugin-svelte'; import resolve from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; -import json from '@rollup/plugin-json'; -import livereload from 'rollup-plugin-livereload'; -import nodeGlobals from 'rollup-plugin-node-globals'; -import nodePolyfills from 'rollup-plugin-node-polyfills'; import sveltePreprocess from 'svelte-preprocess'; import typescript from '@rollup/plugin-typescript'; import replace from '@rollup/plugin-replace'; import css from 'rollup-plugin-css-only'; import copy from 'rollup-plugin-copy'; import { spawn } from 'node:child_process'; +// import livereload from 'rollup-plugin-livereload'; const production = !process.env.ROLLUP_WATCH; const codespaces = process.env.CODESPACES === 'true'; function serve() { - let server; + let server: any; function toExit() { if (server) server.kill(0); } return { + name: 'serve', writeBundle() { // In a codespace, we run the various watcher processes in the // background - if (server || codespaces) { return }; + if (server) { return }; server = spawn('npm', ['run', 'start', '--', '--dev'], { stdio: ['ignore', 'inherit', 'inherit'], @@ -39,20 +38,23 @@ function serve() { }; } -export default { +const config: RollupOptions = { input: 'src/main.ts', output: { - sourcemap: true, + sourcemap: !production, format: 'iife', name: 'app', file: 'public/build/bundle.js' }, plugins: [ replace({ - __buildVersion__: process.env.CF_PAGES_COMMIT_SHA || 'unknown', - __buildBranch__: process.env.CF_PAGES_BRANCH || 'main', + values: { + __buildVersion__: process.env.CF_PAGES_COMMIT_SHA || 'unknown', + __buildBranch__: process.env.CF_PAGES_BRANCH || 'main', + }, + preventAssignment: true, }), - css({ output: 'vendor.css' }), + css({ output: 'vendor.css' }) as any, // FIXME copy({ targets: [ { src: 'fonts/*', dest: 'public/build/fonts' } @@ -63,14 +65,13 @@ export default { compilerOptions: { // enable run-time checks when not in production dev: !production, - // we'll extract any component CSS out into - // a separate file - better for performance - css: css => { - css.write('bundle.css'); - }, + // // we'll extract any component CSS out into-] + // // a separate file - better for performance-] + // css: css => { + // css.write('bundle.css'); + // }, } }), - json(), // If you have external dependencies installed from // npm, you'll most likely need these plugins. In @@ -86,16 +87,14 @@ export default { sourceMap: !production, inlineSources: !production }), - nodeGlobals(), - nodePolyfills(), // In dev mode, call `npm run start` once // the bundle has been generated - !production && serve(), + !production && !codespaces && serve(), // Watch the `public` directory and refresh the // browser on changes when not in production - !production && livereload('public'), + // !production && livereload('public'), // If we're building for production (npm run build // instead of npm run dev), minify @@ -105,3 +104,5 @@ export default { clearScreen: false } }; + +export default config; \ No newline at end of file diff --git a/packages/viewer/src/components/App.svelte b/packages/viewer/src/components/App.svelte index 8f7b349b..de4097a4 100644 --- a/packages/viewer/src/components/App.svelte +++ b/packages/viewer/src/components/App.svelte @@ -1,5 +1,5 @@