diff --git a/package.json b/package.json index 6813193..daa5646 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "type": "commonjs", "main": "dist/src/index.js", "scripts": { - "build": "tsc -p tsconfig.json && mkdir -p dist/web && cp web/index.html web/style.css dist/web/", - "typecheck": "tsc -p tsconfig.json --noEmit", + "build": "tsc -p tsconfig.json && tsc -p tsconfig.web.json && mkdir -p dist/web && cp web/index.html web/style.css dist/web/", + "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.web.json --noEmit", "start": "npm run build && node dist/src/index.js", "test": "npm run build && STEAM_CHAT_DISABLE_AUTOSTART=1 node --test dist/test/*.test.js" }, diff --git a/test/web-build.test.ts b/test/web-build.test.ts new file mode 100644 index 0000000..380253f --- /dev/null +++ b/test/web-build.test.ts @@ -0,0 +1,13 @@ +'use strict'; + +const assert = require('node:assert/strict'); +const fs = require('node:fs'); +const path = require('node:path'); +const test = require('node:test'); + +test('web app build emits a browser-compatible script', () => { + const appPath = path.resolve(__dirname, '../web/app.js'); + const appSource = fs.readFileSync(appPath, 'utf8'); + + assert.doesNotMatch(appSource, /\bexports\b|module\.exports|require\(/); +}); diff --git a/tsconfig.json b/tsconfig.json index 63eaa0a..b5deac7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,5 +13,5 @@ "noImplicitAny": true, "strict": false }, - "include": ["src/**/*.ts", "test/**/*.ts", "web/**/*.ts"] + "include": ["src/**/*.ts", "test/**/*.ts"] } diff --git a/tsconfig.web.json b/tsconfig.web.json new file mode 100644 index 0000000..4eab0df --- /dev/null +++ b/tsconfig.web.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "ES2022", + "rootDir": "web", + "outDir": "dist/web", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "types": [], + "forceConsistentCasingInFileNames": true, + "skipLibCheck": true, + "noImplicitAny": true, + "strict": false + }, + "include": ["web/**/*.ts"] +}