nolanlawson / rollupify

Browserify transform to apply Rollup (UNMAINTAINED)
Apache License 2.0
386 stars 16 forks source link

When a project is big enough, watchify + rollupify stops rebuilding on watch #54

Closed DavidBruant closed 6 years ago

DavidBruant commented 7 years ago

I'm having the problem in this repo https://github.com/dtc-innovation/dataviz-finances-gironde Install with after clone

npm i 
npm run watch

I get the following output :

> dataviz-gironde@1.0.0 watch /home/david/projects/dataviz-finances-gironde
> watchify client/js/main.js -t rollupify -o client/js/browserify-bundle.js -d -v

'redux' is imported by client/js/main.js.tmp, but could not be resolved – treating it as an external dependency
'react' is imported by client/js/main.js.tmp, but could not be resolved – treating it as an external dependency
'react-dom' is imported by client/js/main.js.tmp, but could not be resolved – treating it as an external dependency
'd3-dsv' is imported by client/js/main.js.tmp, but could not be resolved – treating it as an external dependency
'immutable' is imported by client/js/main.js.tmp, but could not be resolved – treating it as an external dependency
'lodash.memoize' is imported by client/js/main.js.tmp, but could not be resolved – treating it as an external dependency
'react-redux' is imported by client/js/main.js.tmp, but could not be resolved – treating it as an external dependency
'immutable' is imported by client/js/finance/hierarchicalAggregated.js, but could not be resolved – treating it as an external dependency
'immutable' is imported by client/js/finance/m52ToAggregated.js, but could not be resolved – treating it as an external dependency
'lodash.memoize' is imported by client/js/objectId.js, but could not be resolved – treating it as an external dependency
'uuid' is imported by client/js/objectId.js, but could not be resolved – treating it as an external dependency
'react' is imported by client/js/components/TopLevel.js, but could not be resolved – treating it as an external dependency
'react' is imported by client/js/components/M52Viz.js, but could not be resolved – treating it as an external dependency
'react' is imported by client/js/components/Sunburst.js, but could not be resolved – treating it as an external dependency
'd3-shape' is imported by client/js/components/Sunburst.js, but could not be resolved – treating it as an external dependency
'react' is imported by client/js/components/SunburstSlice.js, but could not be resolved – treating it as an external dependency
'd3-shape' is imported by client/js/components/SunburstSlice.js, but could not be resolved – treating it as an external dependency
'react' is imported by client/js/components/AggregatedViz.js, but could not be resolved – treating it as an external dependency
'react' is imported by client/js/components/TextualAggregated.js, but could not be resolved – treating it as an external dependency
'react' is imported by client/js/components/TextualSelected.js, but could not be resolved – treating it as an external dependency
'immutable' is imported by client/js/components/TextualSelected.js, but could not be resolved – treating it as an external dependency
'react' is imported by client/js/components/RDFISelector.js, but could not be resolved – treating it as an external dependency
2773384 bytes written to client/js/browserify-bundle.js (3.29 seconds) at 17:02:31

Works fine the first time.

When I edit main.js, the output is as follow:

'redux' is imported by client/js/main.js.tmp, but could not be resolved – treating it as an external dependency
'react' is imported by client/js/main.js.tmp, but could not be resolved – treating it as an external dependency
'react-dom' is imported by client/js/main.js.tmp, but could not be resolved – treating it as an external dependency
'd3-dsv' is imported by client/js/main.js.tmp, but could not be resolved – treating it as an external dependency
'immutable' is imported by client/js/main.js.tmp, but could not be resolved – treating it as an external dependency
'lodash.memoize' is imported by client/js/main.js.tmp, but could not be resolved – treating it as an external dependency
'react-redux' is imported by client/js/main.js.tmp, but could not be resolved – treating it as an external dependency
Error: Could not load uuid (imported by /home/david/projects/dataviz-finances-gironde/client/js/objectId.js): ENOENT: no such file or directory, open 'uuid' while parsing file: /home/david/projects/dataviz-finances-gironde/client/js/main.js

From various testing (including what I did for #53 ), it looks like rollupify is the changing factor that leads to this problem.

I'm on Ubuntu, @oncletom is on OSX but has met the same problem.

DavidBruant commented 7 years ago

I apologize for the vague "When a project is big enough". As can be seen in #53, it works with small projects, but not for bigger ones. But I haven't found the threshold that triggers the bug (whether it's in number of files, dependency depth or file size or something else)

DavidBruant commented 7 years ago

Error: Could not load uuid (imported by /home/david/projects/dataviz-finances-gironde/client/js/objectId.js): ENOENT: no such file or directory, open 'uuid' while parsing file: /home/david/projects/dataviz-finances-gironde/client/js/main.js

Needless to say, the module didn't magically disappear, it's still around. Also, the dependency that "could not be loaded" can change (not always uuid on my project), but I haven't found the criterion leading to a given module not being "ENOENT"-ed. It might be a race condition.

nedkelly commented 7 years ago

I'm having a very similar issue as this, it's seemingly random when running a manual build but always happens if the build is triggered by a watch. browserify -> rollupify -> babelify -> envify running in a gulp task seems to trip over itself resulting in an error.

My Environment: OS: Win32 Node: 6.10.2 npm: 3.10.10 Gulp: 3.9.1

Related Modules: babelify ^7.3.0 browserify ^14.3.0 envify ^4.0.0 rollup-plugin-commonjs ^8.0.2 rollup-plugin-node-resolve-auto ^1.0.1 rollupify ^0.3.9

Example of my test runner task:

let cache;
gulp.task('js', ['js:lint'], () => {
 return gulp.src(['src/*.js'], { read: false })
    .pipe(plumber({ errorHandler: utility.errorHandler }))
    .pipe(tap((file) => {
      file.contents = browserify(file.path, {
        debug: true
      })
      .transform('rollupify', {
        cache: cache,
        plugins: [nodeResolve, rollCommon]
      })
      .transform('babelify', {
        presets: ['es2015']
      })
      .transform('envify', {
        PROJECT_VAR: process.env.PROJECT_VAR
      })
      .on('bundle', (buf) => {
        cache = buf;
      })
      .bundle()
      .on('error', (err) => {
        utility.errorHandler(err, this);
        this.emit('end');
      });
    }))
    .pipe(buffer())
    .pipe(uglify())
    .pipe(gulp.dest('dest/');
});

Resulting Error:

Error: Could not load <dependency_path>.js (imported by D:\<project_dir>\<file_name>.js):
ENOENT: no such file or directory, open 'D:\<project_dir>\<dependency_path>' while parsing file: D:\<project_dir>\<another_file_name>.js

(node:11192) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'emit' of undefined

This seems to happen on projects with a greater amount of node dependencies, I created a small test case with no external dependencies and so far can't reproduce the error there.

Could this be a file locking problem?

brandonocasey commented 7 years ago

I think this is related to https://github.com/rollup/rollup/issues/982

nolanlawson commented 6 years ago

closing stale issues, apparently fixed in rollup 0.50.0