-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When "main" matches source and "browser" field set, bundle fails. #1746
Comments
After some simple A/B testing it appears to me this issue was introduced by v14.1.0. |
The error above is emitted by the readonly stream returned by If I change this line: bundle.pipe(fs.createWriteStream(tmpfile)); to: bundle.pipe(fs.createWriteStream(outfile)); and comment out this this line: // bundle.on('end', successExit); I have no issues. Maybe at some stage the pipeline is expecting the stream to be written to a file matching the specified I've had trouble finding why the |
|
You should always point "main" to a CJS ES5 copy; that's not going to change. |
Sorry, I actually wasn't precise about (or actually stated wrongly) the issue: I want to be able to include a bundled copy of my library as the This actually isn't related to ES2015 (which should work fine with ETA: I could transpile without bundling but I'm using browserify here to create a UMD module for script consumption. |
Right, gotcha. so you're saying if you did |
Correct, I think. If I have: "main": "module.js",
"browser": "dist/module2.js", and run the above, I have a problem. If I delete or change either ETA: So maybe incorrect - I don't think it's related to the base filename (but let me check...) ETA Again: Yeah, unrelated to the actual filenames matching each other. If my |
Any news with that? For example I have been trying to set the property so that I can fix dtjohnson/xlsx-populate#130 but I have no luck. What seems to happen is the following: When
|
It looks like browserify or browser-resolve replaces the path matching the |
I'm having this issue too. I can confirm that the steps to repro are simple:
This seems like a pretty common setup, right? Anyway, I found a workaround:
I'm making a copy of Hopefully this helps others, until a fix is implemented. |
It's a common setup but I don't think it can be fixed without breaking major other use cases. This is just how the |
Both of my files are CommonJS modules, but I still experience this error. {
"main": "lib",
"browser": "lib-es5",
"scripts": {
"posttest": "browserify lib --global-transform [ babelify --presets [ @babel/env ] ] | terser --compress --mangle | gzip-size",
"prepublishOnly": "babel lib/ --out-dir=lib-es5/ --presets=@babel/env --source-maps"
}
} |
I have just encountered this problem with @scottrippey your workaround is great :) |
When you do I'll close this since it's actually the correct behaviour. |
- build a concatenated browser friendly bundle - exorcist for source map support - also fix @module throughout Note for history: the somewhat odd `postbuild` command is intentional. We want to export `lib/browser.js` via `package.json` but doing so causes browserify to rewrite `lib/index.js` to `lib/browser.js`. The copy command breaks this cycle while ensuring that the proper entrypoint is used to produce the concatenated browser bundle. See this Github issue for more details: browserify/browserify#1746 (comment)
- build a concatenated browser friendly bundle - exorcist for source map support - also fix @module throughout Note for history: the somewhat odd `postbuild` command is intentional. We want to export `lib/browser.js` via `package.json` but doing so causes browserify to rewrite `lib/index.js` to `lib/browser.js`. The copy command breaks this cycle while ensuring that the proper entrypoint is used to produce the concatenated browser bundle. See this Github issue for more details: browserify/browserify#1746 (comment)
- build a concatenated browser friendly bundle - exorcist for source map support - also fix @module throughout Note for history: the somewhat odd `postbuild` command is intentional. We want to export `lib/browser.js` via `package.json` but doing so causes browserify to rewrite `lib/index.js` to `lib/browser.js`. The copy command breaks this cycle while ensuring that the proper entrypoint is used to produce the concatenated browser bundle. See this Github issue for more details: browserify/browserify#1746 (comment)
* browserify bundle of botframework-connector - build a concatenated browser friendly bundle - exorcist for source map support - also fix @module throughout Note for history: the somewhat odd `postbuild` command is intentional. We want to export `lib/browser.js` via `package.json` but doing so causes browserify to rewrite `lib/index.js` to `lib/browser.js`. The copy command breaks this cycle while ensuring that the proper entrypoint is used to produce the concatenated browser bundle. See this Github issue for more details: browserify/browserify#1746 (comment) * Remove unused form-data dependency
Using browserify 14.4.0. masOS Sierra.
Quite a weird repro. When running this command:
And under this set of circumstances:
"main"
field in package.json matches the source file ("module.js"
)"browser"
field is also set (with any value, but in our case"dist/module.js"
)We get this error when bundling:
Changing the
"main"
field to something else allows browserify to succeed. Removing the"browser"
field also works. Of course these aren't options for distribution.The text was updated successfully, but these errors were encountered: