davidmyersdev / vite-plugin-node-polyfills

A Vite plugin to polyfill Node's Core Modules for browser environments.
MIT License
263 stars 17 forks source link

cause build slow #17

Closed tjx666 closed 1 year ago

tjx666 commented 1 year ago

bufore using this extension, build cost: 2m 10s after: 3m 38s

before config:

const getNodePolyfill = (module: string) => {
    return {
        find: module,
        replacement: resolveNodeModules('rollup-plugin-node-polyfills/polyfills/', module),
    };
};
const config = {
    resolve: {
            alias: [
                // ppt 导出能力依赖
                getNodePolyfill('stream'),
                getNodePolyfill('os'),
                getNodePolyfill('util'),
            ]
    }
}

after:

{
    plugins: [
        nodePolyfills({
            // Whether to polyfill `node:` protocol imports.
            protocolImports: true,
        }),
    ],
}

Versions:

System:
    OS: macOS 13.2.1
    CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
    Memory: 3.03 GB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.19.1 - ~/Library/Caches/fnm_multishells/58258_1676951390481/bin/node
    npm: 8.19.3 - ~/Library/Caches/fnm_multishells/58258_1676951390481/bin/npm
  Browsers:
    Chrome: 110.0.5481.100
    Chrome Canary: 112.0.5608.0
    Firefox: 109.0.1
    Firefox Developer Edition: 111.0
    Safari: 16.3
  npmPackages:
    rollup: ^3.17.2 => 3.17.2 
    vite: ^4.1.2 => 4.1.2 
davidmyersdev commented 1 year ago

Could you provide a minimal reproduction for me to test against?