Open Dachaz opened 7 years ago
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.
for me the module works fine using the dist file, but every time webpack finishes the compilation, this message shows on the console:
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
Hello there,
I tried using npm version of bootstrap-sweetalert (1.0.1), but when I require() it I get the following:
On the other hand, if I go with "vanilla" sweetalert, I get no such issue.
Any ideas?