-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
parcelRequire is not defined (among other problems) #4389
Comments
This is because we unconditionally create new bundles when we encounter async dependencies, and then deduplicate assets when they're present in all ancestries in the graph. We should either not create the bundle in the first place when encountering the async dependency (this is probably difficult because we don't know all the assets in the bundle until we've fully traversed its children) or remove it after the fact. |
In this case, the runtime for the async dependency when the resolved asset is available already should be something along the lines of |
Will's recent PR doesn't really work for the esmodule output format, the sibling bundle for lodash doesn't export lodash anymore (only the init function): import { $ebea73fc7ce3b38e2743ca9f71cd7c$init } from "./lodash.ea34a757.js";
function $parcel$interopDefault(a) {
return a && a.__esModule ? a.default : a;
}
var $cef71d82488a316df67312338816c3bf$exports = {};
// on here, only the init funciton from above exists, not `.default` = require("lodash")
$cef71d82488a316df67312338816c3bf$exports = import("./" + "lodash.ea34a757.js");
$cef71d82488a316df67312338816c3bf$exports.then(lodash => console.log("async", lodash.add(1, 2)));
var $ebea73fc7ce3b38e2743ca9f71cd7c$$interop$default = $parcel$interopDefault($ebea73fc7ce3b38e2743ca9f71cd7c$init());
console.log("sync", $ebea73fc7ce3b38e2743ca9f71cd7c$$interop$default.add(1, 2)); |
This reverts commit 4d2185f. This temporarily works avoids parcel-bundler/parcel#5683 while we try to see if there is a reasonable workaround for parcel-bundler/parcel#4389 .
…lds. This is a workaround a temporary workaround for a bug that is caused indirectly by our `puzzles` implementation (possibly parcel-bundler/parcel#4389).
This seems to work correctly now (probably because of the async internalization system) |
Got the same error. "parcel": "^2.0.0-beta.2" |
How we can handle this error--- |
🐛 bug report
parcelRequire
is used before it's definedEven when correcting problem (1), the module to import is not defined. Because the sibling bundle
<script>
tag in the html file was inserted after instead of before.After fixing (2), notice that there are actually three bundles (two would make more sense here) and that it contains
so that exports object is missing. (This is the bundle that is dynamically imported).
The corresponding bundle graph is also very odd (an empty bundle?)
💻 Code Sample
🌍 Your Environment
The text was updated successfully, but these errors were encountered: