Compare commits

...

2 Commits

Author SHA1 Message Date
Vinícius Lourenço
ce9e77e433 fix(roles): put the JSON editor error message below its label 2026-11-20 20:14:26 -03:00
Vinícius Lourenço
9926b6e61a fix(frontend): ship Vite workers as ES modules 2026-11-20 18:41:47 -03:00
3 changed files with 38 additions and 0 deletions

View File

@@ -28,6 +28,7 @@
.jsonEditorError {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: var(--spacing-2);
padding: var(--spacing-4) var(--spacing-6);

View File

@@ -0,0 +1,31 @@
import { execFileSync } from 'child_process';
import { resolve } from 'path';
const READ_WORKER_FORMAT = `
(async () => {
const { resolveConfig } = await import('vite');
const config = await resolveConfig(
{ configFile: process.argv[1], mode: 'production' },
'build',
);
process.stdout.write(JSON.stringify(config.worker.format));
})();
`;
describe('Monaco worker bundle', () => {
// An iife worker runs as a sloppy script: the minifier renames on the
// assumption of strict mode, and Annex B hoisting then lets the JSON worker's
// block-level `hasDuplicates` replace the schema collector, so validating any
// non-empty array threw `Cannot read properties of undefined (reading 'include')`.
it('ships workers as ES modules, which always run in strict mode', () => {
const output = execFileSync(
process.execPath,
['--eval', READ_WORKER_FORMAT, resolve(process.cwd(), 'vite.config.ts')],
{ cwd: process.cwd(), encoding: 'utf8' },
);
const format: unknown = JSON.parse(output);
expect(format).toBe('es');
}, 60_000);
});

View File

@@ -189,6 +189,12 @@ export default defineConfig(({ mode }): UserConfig => {
outDir: 'build',
cssMinify: 'esbuild',
},
// An iife worker runs as a sloppy script, where a function declared in a
// block is hoisted as a `var` over the minifier's renamed outer names (the
// JSON worker's validation then throws on every non-empty array).
worker: {
format: 'es',
},
server: {
open: true,
port: 3301,