calvinmetcalf / rollup-plugin-node-builtins

138 stars 40 forks source link

Error: 'nextTick' is not exported by node_modules/process/index.js #53

Open goldenyz opened 5 years ago

goldenyz commented 5 years ago

I have encountered this issue:

[!]  Error: 'nextTick' is not exported by node_modules/process/index.js
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module-
node_modules/_rollup-plugin-node-builtins@2.1.2@rollup-plugin-node-builtins/src/es6/readable-stream/readable.js (10:8)
 8: import {StringDecoder} from 'string_decoder';
 9: import {Duplex} from './duplex';
10: import {nextTick} from 'process';
            ^
11: 
12: var debug = debuglog('stream');

It seems the stream requires a wrong version of 'process'

Below is my rollup config:

export default {
  input: 'src/index.ts',
  output: [
    { file: pkg.main, name: camelCase(libraryName), format: 'umd', sourcemap: true },
    { file: pkg.module, format: 'es', sourcemap: true },
  ],
  // Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
  external: [],
  watch: {
    include: 'src/**',
  },
  plugins: [
    // Allow json resolution
    json(),
    // Compile TypeScript files
    typescript({
      include: ['src/**/*.ts+(|x)'],
    }),
    // Allow node_modules resolution, so you can use 'external' to control
    // which external modules to include in the bundle
    // https://github.com/rollup/rollup-plugin-node-resolve#usage
    resolve({}),
    // Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs)
    commonjs({
      include: ['node_modules/**/*'],
      namedExports: {
        'node_modules/pngjs/browser.js': ['PNG'],
      },
    }),

    // globals and builtins must go after commonjs
    globals(),
    builtins(),

    terser(),

    // Resolve source maps to the original source
    sourceMaps(),
  ],
};

Could anyone help?

torch2424 commented 5 years ago

So just in case anyone else gets this, what I had to do was fork the repo, and replace all instances of including from 'process', with from 'process-es6'.

https://github.com/torch2424/rollup-plugin-node-builtins/commit/e064712dc36631cf39d892558252d8478fb99f5a

It breaks some of the tests, but it works ๐Ÿ˜‚

I'll try and contribute this upstream later ๐Ÿ˜„ ๐Ÿ‘

phtaylor commented 4 years ago

we are now hitting exactly the same problem. There doesn't seem to be much work happening on this repo. Any chance you could setup a pull request for that fix?

torch2424 commented 4 years ago

@phtaylor

So I think I didn't open a PR back then, because I soon learned that my commit actually didn't fix things I don't think?

Looking at my fork commit history: https://github.com/torch2424/rollup-plugin-node-builtins/commits/master

Seems like I was having a really hard time, and I completely forgot what the true problem ended up being unfortunately, since I was juggling a lot of packages doing a lot of weird things :cry: