browserify / browserify/watchify
Silent freeze if source imports non-existant module
- Dominant language
- JavaScript
- Stars
- 1.8k
- Forks
- 178
- PR merge metrics
- No merged PRs in 30d
Description
If `browserify` is given the `watchify` plugin, it will silently freeze if there's an import of a non-existent module anywhere in the source files reachable via `entries`.
I've isolated a minimal complete reproducible example:
src.js:
```javascript
import foobar from 'someNonExistantPackage';
```
gulpfile.js:
```javascript
const gulp = require('gulp');
const watchify = require('watchify');
const browserify = require('browserify');
const vinylSource = require('vinyl-source-stream');
const vinylBuffer = require('vinyl-buffer');
function createBundler() {
return browserify({
entries: ['./src.js'],
}).plugin(watchify);
}
function bundle(bundler) {
return bundler.bundle()
.pipe(vinylSource('dst.js'))
.pipe(vinylBuffer())
.pipe(gulp.dest('./'))
.on('error', console.error)
.on('end', () => { console.log('Done'); });
}
gulp.task('default', () => {
return bundle(createBundler());
});
```
What I expect to happen is for an error to be thrown. I should see it either in `.on('error', console.error)` or by the gulp task crashing. What happens in practice is that the task freezes without printing anything.
If the `watchify` plugin is removed from the chain, then the task continues and errors successfully:
> ParseError: 'import' and 'export' may appear only with 'sourceType: module'
which is expected, because I removed the babel transform from the example to keep it minimal. If babel is added, then `dst.js` is successfully generated as long as `watchify` is not used.
This happens to me on:
* _browserify_ version 16.5.0
* _watchify_ version 3.11.1
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the freeze with the minimal src.js import and gulpfile.js using browserify with the watchify plugin. Start at the bundle task and its error/end handlers, then trace how the missing module is handled; done means the task reports an error instead of silently freezing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100