diff --git a/lib/legacy.ts b/lib/legacy.ts new file mode 100644 index 0000000..63c8783 --- /dev/null +++ b/lib/legacy.ts @@ -0,0 +1,14 @@ +import * as netlib from './index' + +const target: any = + typeof globalThis !== 'undefined' + ? globalThis + : typeof self !== 'undefined' + ? self + : typeof window !== 'undefined' + ? window + : typeof global !== 'undefined' + ? global + : {} + +target.netlib = netlib diff --git a/package.json b/package.json index c4ee2b8..093d1eb 100644 --- a/package.json +++ b/package.json @@ -5,9 +5,29 @@ "source": "lib/index.ts", "main": "dist/netlib.js", "types": "dist/index.d.ts", + "legacy": "dist/legacy.js", + "sideEffects": [ + "lib/legacy.ts" + ], + "targets": { + "types": { + "source": "lib/index.ts" + }, + "main": { + "source": "lib/index.ts" + }, + "legacy": { + "source": "lib/legacy.ts", + "context": "browser", + "outputFormat": "global", + "engines": { + "browsers": "supports es6-module" + }, + "includeNodeModules": true + } + }, "files": [ - "dist/netlib.js", - "dist/netlib.js.map" + "dist/*" ], "scripts": { "prepare": "yarn build",