Skip to content

Commit

Permalink
chore(package): change for tree-shaking + test web export
Browse files Browse the repository at this point in the history
  • Loading branch information
mrspartak committed Jun 16, 2024
1 parent 85360a6 commit ce18090
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
},
"browser": "./dist/web.global.js"
}
},
"sideEffects": false,
Expand Down
8 changes: 1 addition & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,4 @@ import { fromJSONFile } from "./factories/jsonFileFactory.js";
import { fromObject } from "./factories/objectFactory.js";
import { fromURL } from "./factories/urlFactory.js";

const Config = {
fromJSONFile,
fromObject,
fromURL,
};

export { Config };
export { fromJSONFile, fromObject, fromURL };
4 changes: 4 additions & 0 deletions src/web.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { fromObject } from "./factories/objectFactory.js";
import { fromURL } from "./factories/urlFactory.js";

export { fromObject, fromURL };
12 changes: 12 additions & 0 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineConfig } from "tsup";

export default defineConfig([
// Normal build
{
entry: ["./src/index.ts"],
clean: true,
Expand All @@ -9,6 +10,7 @@ export default defineConfig([
dts: true,
outDir: "./dist",
},
// Minified build
{
entry: ["./src/index.ts"],
clean: true,
Expand All @@ -20,4 +22,14 @@ export default defineConfig([
js: format === "cjs" ? ".min.cjs" : ".min.js",
}),
},
// Build for web with source maps and minification
{
entry: ["./src/web.ts"],
clean: true,
format: ["iife"],
minify: true,
sourcemap: true,
outDir: "./dist",
external: ["fs", "path", "os"],
},
]);

0 comments on commit ce18090

Please sign in to comment.