parcel
parcel copied to clipboard
Generated commonJS files with undefined values
🐛 bug report
When building using Parcel a package exporting a dependency from another package the resulting commonJS file contains undefined values.
🎛 Configuration (.babelrc, package.json, cli command)
json workspace-a
{
"name": "workspace-a",
"version": "1.0.0",
"source": "src/index.js",
"main": "dist/main.js",
"module": "dist/module.js",
"dependencies": {
"cross-env": "5.0.5"
}
}
json workspace-b
{
"name": "workspace-b",
"version": "1.0.0",
"source": "src/index.js",
"main": "dist/main.js",
"module": "dist/module.js",
"dependencies": {
"cross-env": "5.0.5",
"workspace-a": "1.0.0"
}
}
🤔 Expected Behavior
The output commonJS file for workspace-b should be:
var $3bJ5v$workspacea = require("workspace-a");
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
$parcel$export(module.exports, "functionB", () => $5d4f15474cde7d38$export$5ab94df7ac192afc);
$parcel$export(module.exports, "functionA", () => $3bJ5v$workspacea.functionA);
const $5d4f15474cde7d38$export$5ab94df7ac192afc = ()=>"functionB";
where $3bJ5v$workspacea
variable is declared and used to access functionA
.
😯 Current Behavior
The output commonJS file for workspace-b is:
var $3bJ5v$workspacea = require("workspace-a");
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
$parcel$export(module.exports, "functionB", () => $5d4f15474cde7d38$export$5ab94df7ac192afc);
$parcel$export(module.exports, "functionA", () => $5d4f15474cde7d38$re_export$functionA);
const $5d4f15474cde7d38$export$5ab94df7ac192afc = ()=>"functionB";
where $3bJ5v$workspacea
variable is declared but not used and $5d4f15474cde7d38$re_export$functionA
is undefined.
💁 Possible Solution
We have seen in another project they are using a patch to make everything working as expected. Is this patch going to be released in the next version?
💻 Code Sample
A repo with a basic set-up using a patch version.
🌍 Your Environment
Software | Version(s) |
---|---|
Parcel | 2.8.2 |
Node | 16.17.1 |
npm/Yarn | 3.3.1 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.
@mischnic We're also having this problem with v2.10.3, would it be possible to reopen this issue? We're also applying the patch linked above, it seems to resolve the issue.