Skip to content

Commit

Permalink
Upgrade deps, enable bundle minification
Browse files Browse the repository at this point in the history
Bundle minification has been enabled because a change in eslint (evanw/esbuild#2721) means some comments are now preserved in the bundle, which isn't useful in the bundle generated for the UI. Minification prevents this.
  • Loading branch information
FlamingTempura committed Mar 4, 2023
1 parent ef495e1 commit 3467580
Show file tree
Hide file tree
Showing 7 changed files with 17,329 additions and 26,484 deletions.
14 changes: 7 additions & 7 deletions bibtex-tidy.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions bin/bibtex-tidy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 21 additions & 21 deletions build.ts
Expand Up @@ -4,7 +4,7 @@ import { transform as swc, type Options, type Output } from '@swc/core';
import { generateDtsBundle } from 'dts-bundle-generator';
import {
build,
serve,
context,
type OnLoadResult,
type OutputFile,
type Plugin,
Expand Down Expand Up @@ -294,7 +294,7 @@ async function buildWebBundle() {
bundle: true,
write: false,
keepNames: true,
banner: { js: jsBanner.join('\n') },
minify: true,
plugins: [
sveltePlugin({ preprocess: autoPreprocess() }),
googleFontPlugin,
Expand All @@ -305,7 +305,8 @@ async function buildWebBundle() {
for (const file of outputFiles) {
let text = file.text;
if (file.path.endsWith('.js')) {
text = (await transpileForOldBrowsers(file)).code;
text = (await transpileForOldBrowsers(file, { minify: true })).code;
text = jsBanner.join('\n') + text;
text = prettier.format(text, { parser: 'babel', printWidth: 400 });
}
await writeFile(file.path, text);
Expand All @@ -315,24 +316,23 @@ async function buildWebBundle() {
}

async function serveWeb() {
const server = await serve(
{ servedir: WEB_PATH },
{
platform: 'browser',
entryPoints: ['./src/ui/index.ts'],
// esbuild replaces the extension, e.g. js for css
outfile: join(WEB_PATH, 'bundle.js'),
bundle: true,
sourcemap: true,
plugins: [
sveltePlugin({
preprocess: autoPreprocess(),
compilerOptions: { enableSourcemap: true },
}),
googleFontPlugin,
],
}
);
const ctx = await context({
platform: 'browser',
entryPoints: ['./src/ui/index.ts'],
// esbuild replaces the extension, e.g. js for css
outfile: join(WEB_PATH, 'bundle.js'),
bundle: true,
sourcemap: true,
write: false,
plugins: [
sveltePlugin({
preprocess: autoPreprocess(),
compilerOptions: { enableSourcemap: true },
}),
googleFontPlugin,
],
});
const server = await ctx.serve({ servedir: WEB_PATH });
console.log(`Access on http://localhost:${server.port}`);
}

Expand Down

0 comments on commit 3467580

Please sign in to comment.