Skip to content

Commit 02b9b14

Browse files
authored
Merge pull request #52 from camptocamp/add-node-dist
Add node-specific bundle in the package
2 parents 5d5663c + 9290d24 commit 02b9b14

File tree

5 files changed

+31
-5
lines changed

5 files changed

+31
-5
lines changed

package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@
6060
"format:check": "prettier --check .",
6161
"lint": "eslint src/**/*.ts",
6262
"lint:fix": "npm run lint -- --fix",
63-
"build": "vite build && esbuild $(find ./src -name \"*.ts\" -type f -not -path '*worker/index.ts' -not -path '*.spec.ts') --outdir=./dist --platform=neutral --format=esm --sourcemap",
63+
"build": "npm run build:worker && npm run build:node && npm run build:browser",
64+
"build:browser": "esbuild $(find ./src -name \"*.ts\" -type f -not -path '*worker/index.ts' -not -path '*.spec.ts') --outdir=./dist --platform=neutral --format=esm --sourcemap",
65+
"build:node": "vite build --config vite.node-config.js",
66+
"build:worker": "vite build --config vite.worker-config.js",
6467
"prepublishOnly": "npm run typecheck && npm test && npm run build",
6568
"typecheck": "tsc --noEmit"
6669
},

src-node/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// @ts-nocheck
2-
import './polyfills';
3-
import { enableFallbackWithoutWorker } from '../src';
4-
export * from '../src/index';
1+
import './polyfills.js';
2+
import { enableFallbackWithoutWorker } from '../src/index.js';
3+
4+
export * from '../src/index.js';
55

66
enableFallbackWithoutWorker();

src-node/polyfills.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
12
// @ts-nocheck
23
import 'regenerator-runtime/runtime';
34
import { EventEmitter } from 'events';

vite.node-config.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { defineConfig } from 'vite';
2+
import { dependencies, devDependencies } from './package.json';
3+
4+
export default defineConfig({
5+
build: {
6+
ssr: true,
7+
rollupOptions: {
8+
external: [/^ol/, 'proj4'],
9+
input: 'src-node/index.ts',
10+
output: {
11+
entryFileNames: 'dist-node.js',
12+
globals: (name) => name,
13+
},
14+
},
15+
outDir: 'dist',
16+
minify: false,
17+
},
18+
ssr: {
19+
noExternal: Object.keys(dependencies).concat(Object.keys(devDependencies)),
20+
target: 'node',
21+
},
22+
});
File renamed without changes.

0 commit comments

Comments
 (0)