Skip to content

Commit 89c1e8a

Browse files
makenowjustkateinoigakukun
authored andcommitted
Bundle Buffer to all browser scripts
Fix #182
1 parent 2b7a25f commit 89c1e8a

File tree

7 files changed

+96
-115
lines changed

7 files changed

+96
-115
lines changed

packages/npm-packages/ruby-3_2-wasm-wasi/package-lock.json

Lines changed: 1 addition & 90 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/npm-packages/ruby-3_2-wasm-wasi/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727
],
2828
"license": "MIT",
2929
"devDependencies": {
30-
"@rollup/plugin-inject": "^5.0.3",
3130
"@rollup/plugin-json": "^6.0.0",
32-
"rollup": "^3.2.2",
33-
"rollup-plugin-polyfill-node": "^0.12.0"
31+
"rollup": "^3.2.2"
3432
}
3533
}
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import inject from "@rollup/plugin-inject";
21
import json from "@rollup/plugin-json";
32
import fs from "fs";
43
import path from "path";
5-
import nodePolyfills from "rollup-plugin-polyfill-node";
64

75
/** @type {import('rollup').RollupOptions[]} */
86
export default [
@@ -15,12 +13,6 @@ export default [
1513
banner: "/* " + fs.readFileSync(path.resolve("../../../NOTICE"), "utf8") + "*/",
1614
}
1715
],
18-
plugins: [
19-
json(),
20-
nodePolyfills(),
21-
inject({
22-
Buffer: ["buffer", "Buffer"],
23-
}),
24-
],
16+
plugins: [json()],
2517
},
2618
];
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import inject from "@rollup/plugin-inject";
21
import json from "@rollup/plugin-json";
32
import fs from "fs";
43
import path from "path";
5-
import nodePolyfills from "rollup-plugin-polyfill-node";
64

75
/** @type {import('rollup').RollupOptions[]} */
86
export default [
@@ -15,12 +13,6 @@ export default [
1513
banner: "/* " + fs.readFileSync(path.resolve("../../../NOTICE"), "utf8") + "*/",
1614
}
1715
],
18-
plugins: [
19-
json(),
20-
nodePolyfills(),
21-
inject({
22-
Buffer: ["buffer", "Buffer"],
23-
}),
24-
],
16+
plugins: [json()],
2517
},
2618
];

packages/npm-packages/ruby-wasm-wasi/package-lock.json

Lines changed: 77 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/npm-packages/ruby-wasm-wasi/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"@babel/core": "^7.19.3",
3434
"@babel/preset-env": "^7.19.3",
3535
"@babel/preset-typescript": "^7.18.6",
36+
"@rollup/plugin-inject": "^5.0.3",
3637
"@rollup/plugin-node-resolve": "^15.0.0",
3738
"@rollup/plugin-typescript": "^10.0.1",
3839
"@types/jest": "^29.1.2",
@@ -42,6 +43,7 @@
4243
"jest": "^29.1.2",
4344
"prettier": "^2.5.1",
4445
"rollup": "^3.2.2",
46+
"rollup-plugin-polyfill-node": "^0.12.0",
4547
"typescript": "^4.5.4"
4648
},
4749
"dependencies": {

packages/npm-packages/ruby-wasm-wasi/rollup.config.mjs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import inject from "@rollup/plugin-inject";
12
import typescript from "@rollup/plugin-typescript";
23
import { nodeResolve } from "@rollup/plugin-node-resolve";
4+
import nodePolyfills from "rollup-plugin-polyfill-node";
35

46
const typescriptOptions = { tsconfig: "./tsconfig.json", declaration: false };
57

6-
function variant(basename) {
8+
function variant(basename, { browser = false } = {}) {
79
return {
810
input: `src/${basename}.ts`,
911
output: [
@@ -23,15 +25,22 @@ function variant(basename) {
2325
exports: "named",
2426
},
2527
],
26-
plugins: [typescript(typescriptOptions), nodeResolve()],
28+
plugins: [
29+
...(browser ? [
30+
nodePolyfills(),
31+
inject({ Buffer: ['buffer', 'Buffer']}),
32+
] : []),
33+
typescript(typescriptOptions),
34+
nodeResolve(),
35+
],
2736
};
2837
}
2938

3039
/** @type {import('rollup').RollupOptions[]} */
3140
export default [
3241
variant("index"),
33-
variant("browser"),
34-
variant("browser.script"),
42+
variant("browser", { browser: true }),
43+
variant("browser.script", { browser: true }),
3544
{
3645
input: `src/node.ts`,
3746
output: [

0 commit comments

Comments
 (0)