npm version seems to compiled incorrectly (or: missing dependencies)
Dachaz opened this issue · 6 comments
Hello there,
I tried using npm version of bootstrap-sweetalert (1.0.1), but when I require() it I get the following:
Error: Cannot find module './handle-dom' from '/tmp/node_modules/bootstrap-sweetalert/dist'
at /tmp/node_modules/browserify/node_modules/resolve/lib/async.js:55:21
at load (/tmp/node_modules/browserify/node_modules/resolve/lib/async.js:69:43)
at onex (/tmp/node_modules/browserify/node_modules/resolve/lib/async.js:92:31)
at /tmp/node_modules/browserify/node_modules/resolve/lib/async.js:22:47
at FSReqWrap.oncomplete (fs.js:82:15)
On the other hand, if I go with "vanilla" sweetalert, I get no such issue.
Any ideas?
I don't think you can simply require
the compiled dist file.
Have you tried to import
(ES6 style) the dev/sweetalert.es6.js
file?
That was not per choice, I just did require('bootstrap-sweetalert')
, and I guess that package.json told it to go for the dist version.
Anyway, I later found sweetalert2 which both works and has the features I need, so you can decide if this ticket is still relevant or not.
Could be relevant as it means supporting another way to include this library into a project.
Could you please post an example in which you require the library (or better a gist of the entire page requiring it)?
i use webpack and babel, and doing a import swal from 'bootstrap-sweetalert'
grabs it from the dist folder, i exclude the node_modules from being parsed by babel for performance reasons and also because is the recommended way to configure webpack, making the assumption that the modules export a es5 compatible script.
I tried to import {SweetAlert} from "bootstrap-sweetalert/dev/sweetalert.es6"
and got the following error:
[16:18:28] gulp-notify: [Compile Error] SyntaxError: Unexpected token (9:7) while parsing [PROJECT_DIR]/node_modules/bootstrap-sweetalert/dev/sweetalert.es6.js while parsing file: [PROJECT_DIR]/node_modules/bootstrap-sweetalert/dev/sweetalert.es6.js
The es6 file contains:
// [...]
import {
hasClass, addClass, removeClass, // and this is the line 9: column 7
escapeHtml,
_show, show, _hide, hide,
isDescendant,
getTopMargin,
fadeIn, fadeOut,
fireClick,
stopEventPropagation
} from './modules/handle-dom';
// [...]
I'm using browserify and babel