Skip to content

Commit

Permalink
chore: bump rollup versions, resolve some rollup warnings
Browse files Browse the repository at this point in the history
and clean out some cruft from the boilerplate rollup config
  • Loading branch information
jamesdabbs committed May 6, 2023
1 parent bad8982 commit 4a93532
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 72 deletions.
17 changes: 9 additions & 8 deletions packages/viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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'],
Expand All @@ -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' }
Expand All @@ -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
Expand All @@ -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
Expand All @@ -105,3 +104,5 @@ export default {
clearScreen: false
}
};

export default config;
2 changes: 1 addition & 1 deletion packages/viewer/src/components/App.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import 'katex/dist/katex.min.css'
// import 'katex/dist/katex.min.css'
import 'bootstrap/dist/css/bootstrap.min.css'
import { Router } from 'svelte-routing'
Expand Down
3 changes: 2 additions & 1 deletion packages/viewer/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "@tsconfig/svelte/tsconfig.json",
"include": [
"src/**/*",
"cypress/**/*"
"cypress/**/*",
"rollup.config.mts"
],
"exclude": [
"rollup.config.js",
Expand Down
Loading

0 comments on commit 4a93532

Please sign in to comment.