fix: build web app as browser module
This commit is contained in:
@@ -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"
|
||||
},
|
||||
|
||||
13
test/web-build.test.ts
Normal file
13
test/web-build.test.ts
Normal file
@@ -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\(/);
|
||||
});
|
||||
@@ -13,5 +13,5 @@
|
||||
"noImplicitAny": true,
|
||||
"strict": false
|
||||
},
|
||||
"include": ["src/**/*.ts", "test/**/*.ts", "web/**/*.ts"]
|
||||
"include": ["src/**/*.ts", "test/**/*.ts"]
|
||||
}
|
||||
|
||||
15
tsconfig.web.json
Normal file
15
tsconfig.web.json
Normal file
@@ -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"]
|
||||
}
|
||||
Reference in New Issue
Block a user