Skip to content

Commit 729b81e

Browse files
committed
roldown(migration): Added nodePolyfills plugin
Completed integration with nodepolyfills plugin.
1 parent 1fea256 commit 729b81e

File tree

5 files changed

+111620
-24
lines changed

5 files changed

+111620
-24
lines changed

__tests__/helpers/index.ts

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import resolve from "@rollup/plugin-node-resolve";
1111
import vue from "rollup-plugin-vue";
1212
import styles from "rollup-plugin-styles";
1313
import externals from "rollup-plugin-node-externals";
14+
import { rolldown } from 'rolldown'
15+
import nodePolyfills from '@rolldown/plugin-node-polyfills'
1416

1517
export interface WriteData {
1618
input: string | string[];
@@ -45,32 +47,44 @@ export const fixture = (...args: string[]): string =>
4547
export async function write(data: WriteData): Promise<WriteResult> {
4648
const outDir = fixture("dist", data.outDir ?? data.title ?? "");
4749
const input = Array.isArray(data.input) ? data.input.map(i => fixture(i)) : fixture(data.input);
48-
const bundle = await rollup({
49-
...data.inputOpts,
50+
// const bundle = await rollup({
51+
// ...data.inputOpts,
52+
// input,
53+
// plugins: [
54+
// externals({ deps: true }),
55+
// json(),
56+
// resolve({
57+
// preferBuiltins: true,
58+
// dedupe: [
59+
// "vue",
60+
// "@vue/compiler-core",
61+
// "@vue/compiler-dom",
62+
// "@vue/compiler-sfc",
63+
// "@vue/compiler-ssr",
64+
// "@vue/reactivity",
65+
// "@vue/runtime-core",
66+
// "@vue/runtime-dom",
67+
// "@vue/shared",
68+
// ],
69+
// }),
70+
// vue3ui({ debug: true }),
71+
// vue({ preprocessStyles: false }),
72+
// styles({ mode: "extract" }),
73+
// ],
74+
// });
75+
const bundle = await rolldown({
76+
// ... other config
5077
input,
5178
plugins: [
52-
externals({ deps: true }),
53-
json(),
54-
resolve({
55-
preferBuiltins: true,
56-
dedupe: [
57-
"vue",
58-
"@vue/compiler-core",
59-
"@vue/compiler-dom",
60-
"@vue/compiler-sfc",
61-
"@vue/compiler-ssr",
62-
"@vue/reactivity",
63-
"@vue/runtime-core",
64-
"@vue/runtime-dom",
65-
"@vue/shared",
66-
],
79+
nodePolyfills({
80+
// Optional configuration
81+
include: ['fs', 'path'], // Only polyfill specific modules
82+
exclude: ['crypto'], // Exclude modules from polyfilling
6783
}),
68-
vue3ui({ debug: true }),
69-
vue({ preprocessStyles: false }),
70-
styles({ mode: "extract" }),
84+
// ... other plugins
7185
],
72-
});
73-
86+
platform: 'node' // Important for Node.js polyfilling
87+
})
7488
const { output } = await bundle.write({
7589
...data.outputOpts,
7690
dir: data.outputOpts?.file ? undefined : outDir,

bun.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"@commitlint/prompt-cli": "^11.0.0",
2828
"@pathscale/bulma-extensions-css-var": "0.0.49-3",
2929
"@pathscale/vue3-ui": "^0.8.146",
30+
"@rolldown/plugin-node-polyfills": "1.0.0",
3031
"@rollup/plugin-babel": "^5.2.2",
3132
"@rollup/plugin-commonjs": "^17.0.0",
3233
"@rollup/plugin-json": "^4.1.0",
@@ -447,6 +448,8 @@
447448

448449
"@rolldown/binding-win32-x64-msvc": ["@rolldown/[email protected]", "https://registry.npmmirror.com/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.0.0-beta.8.tgz", { "os": "win32", "cpu": "x64" }, "sha512-hR81d84Poe6oIxaz4PnWBLVF0VuqtRfISIyXQAgk2etu2udrKnWKr3A+xqXe9ELjbLlRYGvEm2dlw/cldO9Kxg=="],
449450

451+
"@rolldown/plugin-node-polyfills": ["@rolldown/[email protected]", "https://registry.npmmirror.com/@rolldown/plugin-node-polyfills/-/plugin-node-polyfills-1.0.0.tgz", {}, "sha512-JUmEhvz+B6+0AaeUGvZ7SnJec7wpwYqZ+FcAng1I3UVGYKA1uSmE1H4vKHUewU665Nb37znDd9N4o/iImmKeVg=="],
452+
450453
"@rollup/plugin-babel": ["@rollup/[email protected]", "", { "dependencies": { "@babel/helper-module-imports": "^7.10.4", "@rollup/pluginutils": "^3.1.0" }, "peerDependencies": { "@babel/core": "^7.0.0", "@types/babel__core": "^7.1.9", "rollup": "^1.20.0||^2.0.0" }, "optionalPeers": ["@types/babel__core"] }, "sha512-WFfdLWU/xVWKeRQnKmIAQULUI7Il0gZnBIH/ZFO069wYIfPu+8zrfp/KMW0atmELoRDq8FbiP3VCss9MhCut7Q=="],
451454

452455
"@rollup/plugin-commonjs": ["@rollup/[email protected]", "", { "dependencies": { "@rollup/pluginutils": "^3.1.0", "commondir": "^1.0.1", "estree-walker": "^2.0.1", "glob": "^7.1.6", "is-reference": "^1.2.1", "magic-string": "^0.25.7", "resolve": "^1.17.0" }, "peerDependencies": { "rollup": "^2.30.0" } }, "sha512-PoMdXCw0ZyvjpCMT5aV4nkL0QywxP29sODQsSGeDpr/oI49Qq9tRtAsb/LbYbDzFlOydVEqHmmZWFtXJEAX9ew=="],

0 commit comments

Comments
 (0)