The v4 alpha 3 (just released) npm package does not contain as ./dist/js/npm referenced in the package.json.
This causes problems when requiring or importing the bootstrap package via npm.
I am not sure if the file is missing or purposely removed (in which case the package.json would need to be updated)
Update:
Commit which removed the file: https://github.com/twbs/bootstrap/commit/ce2e944aa6957528f23f1f7e680ac0cb4a75dcac
@cvrebert Is this something we need to restore, or is there another solution here? I'm unsure what I can do to resolve this and, if there's a fix, I'd like to include it in the "alpha patch" I've queued up.
I'm not entirely sure about the decision to only ship ES6 files in the npm package, introduced by #20072...
In the application I'm working on, we do indeed have Babel + Webpack, but we only run it on our own source files (and with Babel presets specific to our project, since there are different "flavors" of ES6). All the packages in our node_modules/ are already pre-transpiled to ES5 (React, etc.). I have yet to come across an npm package that only publishes ES6 source files (I guess you can publish both ES5 and ES6 if you'd like).
Our use-case is that we only bundle the JS we need from Bootstrap. An example from one of our Webpack entry points:
window.jQuery = require('jquery');
require('bootstrap/dist/js/umd/dropdown.js');
This would work if we required ES5 CommonJS (it doesn't have to be UMD), but it wouldn't if it was ES6.
Long story short, I would publish on npm:
dist/js/bootstrap.js (and bootstrap.min.js): the ES5 UMD build (usable by any setup, can also point the package.json main to this)lib/dropdown.js, etc.: the transpiled ES5 CommonJS modules, usable by Webpack, Browserify etc. (without forcing Babel, can cause headaches if you don't have the right Babel version or are not using the right presets)src/dropdown.js, etc.: the original ES6 modules(Folder names are given as example, feel free to change them.)
Others may have different opinions, but I just wanted to raise a flag on publishing only the ES6 modules and full UMD build 馃槃 I think we should also have the ES5 CommonJS.
@mdo No need to resurrect anything. Probably we should change main to point at dist/js/bootstrap.js (or maybe the minified version; will try to do some looking soon).
we should change
mainto point atdist/js/bootstrap.js
looks like #20394 is doing just that
I am having the same issue as @TheSharpieOne, it is kinda unfortunate that I have to go back to alpha2 because of it. Or does anyone have a workaround for this?
Small side-question: why is it still called an alpha? Isn't it stable enough to call it a beta? Or do you want to call it a beta when most of the breaking changes have been released?
@Zyphrax the current workaround is to change import 'bootstrap'; to import 'bootstrap/dist/js/bootstrap'; (referencing the file directly).
Or if you are not using the es2015 module syntax: change require('bootstrap') to require('bootstrap/dist/js/bootstrap'); This workaround works for me.
I cannot/should not really speak to the alpha beta thing, but yes, I believe it is still alpha because there are still some components which have not need fully flushed out in v4 and breaking changes happen all of the time (usually for good reasons #notcomplaining).
Thank you. I'm importing the (s)css of Bootstrap in my project (es6 notation). That seems to trigger Webpack to include the javascript code of Bootstrap and then throws an error that the bootstrap module could not be found. I'm not really sure how I can work around that.
Merged #20394, and followed up with #20552, to update the package.json in v4-dev. Working with the team to find a date to ship the next release.
Most helpful comment
I'm not entirely sure about the decision to only ship ES6 files in the npm package, introduced by #20072...
In the application I'm working on, we do indeed have Babel + Webpack, but we only run it on our own source files (and with Babel presets specific to our project, since there are different "flavors" of ES6). All the packages in our
node_modules/are already pre-transpiled to ES5 (React, etc.). I have yet to come across an npm package that only publishes ES6 source files (I guess you can publish both ES5 and ES6 if you'd like).Our use-case is that we only bundle the JS we need from Bootstrap. An example from one of our Webpack entry points:
This would work if we required ES5 CommonJS (it doesn't have to be UMD), but it wouldn't if it was ES6.
Long story short, I would publish on npm:
dist/js/bootstrap.js(andbootstrap.min.js): the ES5 UMD build (usable by any setup, can also point thepackage.jsonmainto this)lib/dropdown.js, etc.: the transpiled ES5 CommonJS modules, usable by Webpack, Browserify etc. (without forcing Babel, can cause headaches if you don't have the right Babel version or are not using the right presets)src/dropdown.js, etc.: the original ES6 modules(Folder names are given as example, feel free to change them.)
Others may have different opinions, but I just wanted to raise a flag on publishing only the ES6 modules and full UMD build 馃槃 I think we should also have the ES5 CommonJS.