I know you guys are working on V2, but I thought I should still post this issue, especially since I found kind of a workaround:
š bug report
When I enable scopeHoist, I am getting errors for a specific package: GSAP.
scopeHoist Error: "node_modules/gsap/all.js does not export 'gsap'"
All other npm modules are working as expected. I first posted an issue over at the GSAP forums, but it seems to be related to parcel, not GSAP. I double-checked in node_modules/gsap/all.js and it does actually export gsap:
// ...
export { gsapWithCSS as gsap, gsapWithCSS as default, CSSPlugin, TweenMaxWithCSS as TweenMax };
// ...
š Configuration
My setup: I have a main entry file app.js for parcel. In there, I only import the main js and scss files:
As you can see, the ./js/app/index is being imorted the Side effects only way. Inside ./js/app/index I have the actual GSAP-import, alongside many other node_modules and my main App's logic :
// ...
// GSAP import, as described here: https://www.youtube.com/watch?v=znVi89_gazE
import { gsap, CustomEase, ScrollToPlugin, Power4, Linear } from 'gsap/all';
gsap.registerPlugin(CustomEase, ScrollToPlugin);
gsap.registerEase(Linear, Power4);
// ...
š¤ Expected Behavior
scopeHoist should work just like with all the other node_modules
šÆ Current Behavior
scopeHoist doesn't work with a Side Effects Only-import, but only with the GSAP package. Error Message and stack trace (I replaced the path to node_modules with [...]):
šØ ../node_modules/gsap/all.js does not export 'gsap'
at replaceExportNode ([...]/node_modules/parcel-bundler/src/scope-hoisting/concat.js:55:13)
at ReferencedIdentifier ([...]/node_modules/parcel-bundler/src/scope-hoisting/concat.js:342:20)
at newFn ([...]/node_modules/@babel/traverse/lib/visitors.js:220:17)
at NodePath._call ([...]/node_modules/@babel/traverse/lib/path/context.js:55:20)
at NodePath.call ([...]/node_modules/@babel/traverse/lib/path/context.js:42:17)
at NodePath.visit ([...]/node_modules/@babel/traverse/lib/path/context.js:90:31)
at TraversalContext.visitQueue ([...]/node_modules/@babel/traverse/lib/context.js:112:16)
at TraversalContext.visitSingle ([...]/node_modules/@babel/traverse/lib/context.js:84:19)
at TraversalContext.visit ([...]/node_modules/@babel/traverse/lib/context.js:140:19)
at Function.traverse.node ([...]/node_modules/@babel/traverse/lib/index.js:84:17)
(node:67722) UnhandledPromiseRejectionWarning: Error: ../node_modules/gsap/all.js does not export 'gsap'
at replaceExportNode ([...]/node_modules/parcel-bundler/src/scope-hoisting/concat.js:55:13)
at ReferencedIdentifier ([...]/node_modules/parcel-bundler/src/scope-hoisting/concat.js:342:20)
at newFn ([...]/node_modules/@babel/traverse/lib/visitors.js:220:17)
at NodePath._call ([...]/node_modules/@babel/traverse/lib/path/context.js:55:20)
at NodePath.call ([...]/node_modules/@babel/traverse/lib/path/context.js:42:17)
at NodePath.visit ([...]/node_modules/@babel/traverse/lib/path/context.js:90:31)
at TraversalContext.visitQueue ([...]/node_modules/@babel/traverse/lib/context.js:112:16)
at TraversalContext.visitSingle ([...]/node_modules/@babel/traverse/lib/context.js:84:19)
at TraversalContext.visit ([...]/node_modules/@babel/traverse/lib/context.js:140:19)
at Function.traverse.node ([...]/node_modules/@babel/traverse/lib/index.js:84:17)
(node:67722) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:67722) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
š Possible Solution
I was able to 'fix' the issue by giving the ./js/app/index-import in the main entry file a name, like this:
// Named import to fix scopeHoisting:
import App from './js/app/index';
import './scss/app.scss';
I know you guys are working on V2, but I thought I should still post this issue, especially since I found kind of a workaround:
š bug report
When I enable
scopeHoist
, I am getting errors for a specific package: GSAP.All other npm modules are working as expected. I first posted an issue over at the GSAP forums, but it seems to be related to parcel, not GSAP. I double-checked in
node_modules/gsap/all.js
and it does actually exportgsap
:š Configuration
My setup: I have a main entry file
app.js
for parcel. In there, I only import the mainjs
andscss
files:As you can see, the
./js/app/index
is being imorted the Side effects only way. Inside./js/app/index
I have the actual GSAP-import, alongside many othernode_modules
and my main App's logic :š¤ Expected Behavior
scopeHoist
should work just like with all the other node_modulesšÆ Current Behavior
scopeHoist
doesn't work with a Side Effects Only-import, but only with the GSAP package. Error Message and stack trace (I replaced the path tonode_modules
with[...]
):š Possible Solution
I was able to 'fix' the issue by giving the
./js/app/index
-import in the main entry file a name, like this:š Your Environment