Skip to content

Commit

Permalink
refactor: strip process.env from UMD build (#2)
Browse files Browse the repository at this point in the history
* refactor: strip process.env from UMD build

* chore: add test/try.html
  • Loading branch information
hyrious authored Jul 16, 2024
1 parent 02cfb5f commit 59abcc4
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 45 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules/
dist/
public/
pnpm-lock.yaml
*.html
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
},
"devDependencies": {
"@jest/globals": "^29.5.0",
"@rollup/plugin-replace": "^5.0.7",
"@size-limit/esbuild": "^11.1.4",
"@size-limit/file": "^11.1.4",
"@types/node": "^18.15.0",
Expand Down
119 changes: 74 additions & 45 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions scripts/build-umd.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import replace from "@rollup/plugin-replace";
import fs from "node:fs";
import prettyBytes from "pretty-bytes";
import { rollup } from "rollup";
Expand All @@ -10,6 +11,14 @@ fs.writeFileSync(

const bundle = await rollup({
input: "dist/temp.mjs",
plugins: [
replace({
preventAssignment: true,
values: {
"process.env.NODE_ENV": '"production"',
},
}),
],
});

const { output } = await bundle.write({
Expand Down
11 changes: 11 additions & 0 deletions test/try.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>Try ValueEnhancer in Browser</title>
<meta name="viewport" content="width=device-width" />
</head>
<body>
<p>Open console and try <code>`ValueEnhancer`</code>.</p>
<script src="../dist/index.umd.js"></script>
</body>
</html>

0 comments on commit 59abcc4

Please sign in to comment.