Skip to content
This repository was archived by the owner on Apr 8, 2024. It is now read-only.

Commit 673dd23

Browse files
authored
feat: strip node: prefixes from our dists (#8)
1 parent 0cd3d8b commit 673dd23

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tsup.config.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,34 @@ import type { Options } from 'tsup';
33
// eslint-disable-next-line import/no-extraneous-dependencies
44
import { defineConfig } from 'tsup';
55

6+
/**
7+
* Webpack unfortunately does not support the `node:` prefix making it impossible to polyfill the
8+
* `node:stream` and `node:util` libraries that we use here so we're removing it when we generate
9+
* our dists.
10+
*
11+
* @see {@link https://github.com/evanw/esbuild/issues/1760#issuecomment-964900401}
12+
* @see {@link https://github.com/webpack/webpack/issues/14166}
13+
*/
14+
const stripNodeColonPlugin = {
15+
name: 'strip-node-colon',
16+
setup({ onResolve }) {
17+
onResolve({ filter: /^node:/ }, args => {
18+
return {
19+
path: args.path.slice('node:'.length),
20+
external: true,
21+
};
22+
});
23+
},
24+
};
25+
626
export default defineConfig((options: Options) => ({
727
...options,
828

929
cjsInterop: true,
1030
clean: true,
1131
dts: true,
1232
entry: ['src/index.ts'],
33+
esbuildPlugins: [stripNodeColonPlugin],
1334
format: ['esm', 'cjs'],
1435
minify: false,
1536
shims: true,

0 commit comments

Comments
 (0)