smooth-scrollbar
smooth-scrollbar copied to clipboard
Compile error - when using rollup babel
Hello,
I'm getting a compile error when I import the module
[Compile Error] Unexpected token (4:20367) in /Users/magicspon/websites/mudstone/node_modules/smooth-scrollbar/dist/smooth-scrollbar.js
As the code is minified so I can't really see where it's failing. I'm not sure if this is an issue with rollup babel.
This is my rollup config (using gulp)
plugins: [
resolve({
jsnext: true,
main: true,
browser: true
}),
commonjs({
include: 'node_modules/**'
}),
eslint({
exclude: $js.lint.ignore
}),
babel({
exclude: 'node_modules/**',
presets: [
'stage-0',
['es2015', { 'modules': false }]
],
plugins: [
'external-helpers',
'syntax-object-rest-spread',
'transform-es2015-parameters',
'transform-es2015-destructuring',
'transform-object-rest-spread'
],
babelrc: false,
runtimeHelpers: true
}),
replace({
ENV: JSON.stringify(process.env.NODE_ENV || 'development')
}),
(process.env.NODE_ENV === 'production' && uglify())
]
Any ideas?
Thanks
Sorry I'm not familiar with rollup, can you provide more details about the error outputs?
Hello,
[Compile Error] Unexpected token (4:20367) in /Users/magicspon/websites/mudstone/node_modules/smooth-scrollbar/dist/smooth-scrollbar.js
I'm afraid that is the entire error message I get.
I made a clone of this repo, ran npm run dist
with the ugilify stuff commented out and copied the output into my project node_modules.
I then got this error:
[22:57:40] gulp-notify: [Compile Error] Unexpected token (1783:35) in /Users/magicspon/websites/mudstone/node_modules/smooth-scrollbar/dist/smooth-scrollbar.js in
Line 1783 below
if (typeof _shared.GLOBAL_ENV.MutationObserver === 'function') {
// observe
var observer = new _shared.GLOBAL_ENV.MutationObserver(function () {
_this.update(true); // <!---- LINE 183
});
observer.observe(content, {
childList: true
});
Object.defineProperty(this, '__observer', {
value: observer
});
}
I can't see anything wrong with that snippet of code... I tried commenting it out to see if there were more errors, the next one was very similar, code looks totally fine.
[22:58:49] gulp-notify: [Compile Error] Unexpected token (1811:43) in /Users/magicspon/websites/mudstone/node_modules/smooth-scrollbar/dist/smooth-scrollbar.js in
line 1811 below:
_createClass(SmoothScrollbar, [{
key: 'MAX_OVERSCROLL',
get: function get() {
var options = this.options,
size = this.size;
switch (options.overscrollEffect) {
case 'bounce':
var diagonal = Math.floor(Math.sqrt(Math.pow(size.container.width, 2) + Math.pow(size.container.height, 2)));
var touchFactor = this.__isMovementLocked() ? 2 : 10;
return _shared.GLOBAL_ENV.TOUCH_SUPPORTED ? (0, _utils.pickInRange)(diagonal / touchFactor, 100, 1000) : (0, _utils.pickInRange)(diagonal / 10, 25, 50);
break;
case 'glow':
return 150; // <!-- LINE 1811
default:
return 0;
}
}
}
very odd
I've made an example in this repo:
https://github.com/magicspon/smooth-scrollbar-issue
npm i
npm run scripts
Cheers
That is so weird...can you just exclude smooth-scrollbar
from rollup until I can figure out what's going on?
Hi,
I don't have a solution but I do have the same problem compiling with RollupJs
Unexpected token node_modules/smooth-scrollbar/dist/smooth-scrollbar.js (4:20359)
8.0.0 is now published with pkg.module
field. Can you try it again and see whether the problem is resolved?
I used to integrate gulp with webpack
(webpack-stream) or with rollup
🤣
If you still using gulp better look at this boilerplate and also update the package.json modules
https://github.com/jh3y/gulp-boilerplate
also, test smooth-scrollbar
with rollup-starter-app it works without problem