From: Chris Duncan Date: Fri, 1 Nov 2024 04:38:58 +0000 (-0700) Subject: Add separate file option to allow importing to the global namespace. X-Git-Tag: v0.0.15~1 X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=fd4a7c90c6a9925a809fab758d8311854d06f147;p=libnemo.git Add separate file option to allow importing to the global namespace. --- diff --git a/package.json b/package.json index 40250a9..33d7a2e 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "url": "git+https://zoso.dev/libnemo.git" }, "scripts": { - "build": "rm -rf dist && tsc && esbuild dist/main.js --outfile=dist/main.min.js --target=es2022 --format=esm --platform=browser --bundle --minify --sourcemap", + "build": "rm -rf dist && tsc && esbuild main.min=dist/main.js global.min=dist/global.js --outdir=dist --target=es2022 --format=esm --platform=browser --bundle --minify --sourcemap", "test": "npm run build && node --test --env-file .env", "test:coverage": "npm run test -- --experimental-test-coverage", "test:coverage:report": "npm run test:coverage -- --test-reporter=lcov --test-reporter-destination=coverage.info && genhtml coverage.info --output-directory test/coverage && rm coverage.info && xdg-open test/coverage/index.html" diff --git a/src/global.ts b/src/global.ts new file mode 100644 index 0000000..083e4b9 --- /dev/null +++ b/src/global.ts @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2024 Chris Duncan +// SPDX-License-Identifier: GPL-3.0-or-later + +import * as libnemo from './main.js' +Object.defineProperty(globalThis, 'libnemo', libnemo) diff --git a/tsconfig.json b/tsconfig.json index b544969..1dab653 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,6 +16,7 @@ }, "include": [ "src/main.ts", + "src/global.ts", "src/*", "src/**/*" ]