question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Flag for scope-hoisting in serve/watch mode

See original GitHub issue

🐛 bug report

I’m trying to import node package into my app, package has ‘main’ and ‘module’ props in it’s package.json:

"main": "dist/index.js",
"module": "src/index.js",

as result with parcel@v1 it works ok - package is imported as module, but using parcel@next or parcel@nightly gives me following error:

@parcel/resolver-default:
"main": "dist/index.js",
>    |           ^^^^^^^^^^^^^^^^^^^^^ './dist/index.js' does not existundefined'

even though dist/index.js doesn’t exist, why it’s loaded instead of ‘module’ source?

🎛 Configuration (.babelrc, package.json, cli command)

no config

🤔 Expected Behavior

importing package as module

😯 Current Behavior

importing package main dist

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
sergey-shpakcommented, Oct 26, 2020

@mischnic ok, thanks! Anyway, it would be nice to have more transparency and control over scope hoisting, something opposite param to --no-scope-hoist, like --with-scope-hoist (default for build, and optional for watch/serve)

1reaction
mischniccommented, Oct 26, 2020

Ah, two reasons:

  • it’s very slow
  • HMR (with scope-hoisting, individual files cannot be swapped out at runtime)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Scope hoisting - Parcel
In production builds, Parcel concatenates modules into a single scope. This is called "scope hoisting". Parcel also statically analyzes the imports and ...
Read more >
Understanding Hoisting in Javascript | by Swati Sucharita
Hoisting means moving something up like with a rope like flag ... Javascript moves the variable declaration to the top of the scope....
Read more >
JavaScript Hoisting - W3Schools
Hoisting is JavaScript's default behavior of moving declarations to the top. ... current scope (to the top of the current script or the...
Read more >
JavaScript Hoisting - GeeksforGeeks
In JavaScript, Hoisting is the default behavior of moving all the declarations at the top of the scope before code execution.
Read more >
Understanding Hoisting in JavaScript - DigitalOcean
As we've seen above, variables within a global scope are hoisted to the top ... By enabling strict mode, we opt into a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found