theKashey / react-remove-scroll

Removes and disables 📜in a "React" way
MIT License
784 stars 28 forks source link

Fix Attempted import error: '__spreadArray' is not exported from 'tslib' #70

Closed ellanan closed 2 years ago

ellanan commented 2 years ago

The current SideEffect.js gets transpiled to import import { __spreadArray } from "tslib"; https://unpkg.com/react-remove-scroll@2.5.3/dist/es2015/SideEffect.js

__spreadArray was not added into tslib until 2.1.0

The current dependency on "tslib": "^2.0.0", is resulting in fresh installs installing tslib 2.0.3 and erroring with Attempted import error: '__spreadArray' is not exported from 'tslib'

ellanan commented 2 years ago

For anyone else running into this and using webpack, a workaround is to alias tslib to tslib: '/node_modules/tslib/tslib.es6.js' so it uses the version at your project root rather than the one in react-remove-scroll's node_modules

bihnkim commented 2 years ago

@ellanan could I trouble you to explain how you ran into this error? I run into this same error compiling from a rails + webpacker app, yet I do not have this error in a barebones create-react-app I spun up for testing.

Edit: the CRA is running node v16, the rails app is running node v12 if that matters

theKashey commented 2 years ago

It's all depend on the version of tslib you already have.

ellanan commented 2 years ago

This was an old project, I ran into it while upgrading its chakra version from 0.8 to 2.0

One of the other dependencies had already triggered tslib 2.0.3 to be installed and that happened to satisfy this library's requirement of "tslib": "^2.0.0"