]> zoso.dev Git - libnemo.git/commitdiff
Add separate file option to allow importing to the global namespace.
authorChris Duncan <chris@zoso.dev>
Fri, 1 Nov 2024 04:38:58 +0000 (21:38 -0700)
committerChris Duncan <chris@zoso.dev>
Fri, 1 Nov 2024 04:38:58 +0000 (21:38 -0700)
package.json
src/global.ts [new file with mode: 0644]
tsconfig.json

index 40250a96a752bdd05c92ec3f2cd1e4dc14851976..33d7a2ef043d5b9d825a7e08e0983b24c0513ac2 100644 (file)
@@ -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 (file)
index 0000000..083e4b9
--- /dev/null
@@ -0,0 +1,5 @@
+// SPDX-FileCopyrightText: 2024 Chris Duncan <chris@zoso.dev>
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+import * as libnemo from './main.js'
+Object.defineProperty(globalThis, 'libnemo', libnemo)
index b544969758992b174a7e7a1ba01dde300c2ab9cd..1dab65334384a660bafd8f5766c19531d494a5e0 100644 (file)
@@ -16,6 +16,7 @@
        },
        "include": [
                "src/main.ts",
+               "src/global.ts",
                "src/*",
                "src/**/*"
        ]