lipis / bootstrap-sweetalert

:cake: A beautiful "replacement" for JavaScript's alert ⛺
https://lipis.github.io/bootstrap-sweetalert/
MIT License
2.1k stars 503 forks source link

npm version seems to compiled incorrectly (or: missing dependencies) #65

Open Dachaz opened 7 years ago

Dachaz commented 7 years ago

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?

alekitto commented 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?

Dachaz commented 7 years ago

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.

alekitto commented 7 years ago

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)?

CesarLanderos commented 7 years ago

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.

CesarLanderos commented 7 years ago

for me the module works fine using the dist file, but every time webpack finishes the compilation, this message shows on the console:

screen shot 2017-01-26 at 8 20 43 pm

pwqw commented 7 years ago

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