bootboxjs / bootbox

Wrappers for JavaScript alert(), confirm() and other flexible dialogs using Twitter's bootstrap framework
http://bootboxjs.com
Other
5.04k stars 1.04k forks source link

5.x.x NPM version throws an error Cannot find module './bootbox' #700

Closed mtrunkat closed 5 years ago

mtrunkat commented 5 years ago

We have just tried to update from version 4.x to 5.x. After update following error appear in Chrome console:

Uncaught Error: Cannot find module './bootbox'
    at makeMissingError (modules-runtime.js?hash=d3c3e5d67c95f97a60888bda7373292efad3be5e:232)
    at Module.require (modules-runtime.js?hash=d3c3e5d67c95f97a60888bda7373292efad3be5e:251)
    at require (modules-runtime.js?hash=d3c3e5d67c95f97a60888bda7373292efad3be5e:268)
    at modules.js?hash=67bedc1ab4c98fec2f87c653323b8bba64c19b2c:123863
    at bootbox.all.min.js (modules.js?hash=67bedc1ab4c98fec2f87c653323b8bba64c19b2c:123863)
    at fileEvaluate (modules-runtime.js?hash=d3c3e5d67c95f97a60888bda7373292efad3be5e:346)
    at Module.require (modules-runtime.js?hash=d3c3e5d67c95f97a60888bda7373292efad3be5e:248)
    at Module.moduleLink [as link] (modules.js?hash=67bedc1ab4c98fec2f87c653323b8bba64c19b2c:349)
    at tou_agreement.js (tou_agreement.js:1)
    at fileEvaluate (modules-runtime.js?hash=d3c3e5d67c95f97a60888bda7373292efad3be5e:346)
    at Module.require (modules-runtime.js?hash=d3c3e5d67c95f97a60888bda7373292efad3be5e:248)
    at Module.moduleLink [as link] (modules.js?hash=67bedc1ab4c98fec2f87c653323b8bba64c19b2c:349)
    at index.js (index.js:1)
    at fileEvaluate (modules-runtime.js?hash=d3c3e5d67c95f97a60888bda7373292efad3be5e:346)
    at Module.require (modules-runtime.js?hash=d3c3e5d67c95f97a60888bda7373292efad3be5e:248)
    at Module.moduleLink [as link] (modules.js?hash=67bedc1ab4c98fec2f87c653323b8bba64c19b2c:349)

Tested on OS X + Node.js v8.12.0 with Meteor.js framework which bundles frontend build using Webpack.

After looking into code of the package I think that the problem is in ./dist/bootbox.all.min.js which requires a ./bootbox.js via require('./bootbox') but this file is not contained in ./dist/ directory.

tiesont commented 5 years ago

Sorry, not an NPM user myself, or I would have caught this sooner.

That require is actually part of bootbox.locales.js, which is combined with bootbox.js to create a single file with all locales. Probably not the right way to generate a file with all locales. I'll see if I can come up with a better grunt task. If you only need the en locale (the default), are you able to tell Webpack to use bootbox.min.js instead, in the meanwhile?

The original idea was to pull in all the individual files from the locales directory. Having a distinct file for each locale should, in theory, make it easier to create new locales, since you're only editing one locale at a time.

mtrunkat commented 5 years ago

What about to just point main property of package.json file to src/bootbox.js instead of dist/...?

tiesont commented 5 years ago

I can do that, I suppose. The thought was that pointing to the bootbox.all file was the least breaking change, since Bootbox 4 included all the locales in the single source file. In Bootbox 5, I only left the en locale in bootbox.js, since that's the default locale.

tiesont commented 5 years ago

I changed the bootbox.all.min.js file to be built from a new source file, bootbox.all.js, which uses the 4.x version of defining locales (one large array). Just pushed this to npm - if you can let me know if that works, I'd appreciate it.