Skip to content
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

Generated commonJS files with undefined values #8764

Open
luca-tardito opened this issue Jan 12, 2023 · 3 comments
Open

Generated commonJS files with undefined values #8764

luca-tardito opened this issue Jan 12, 2023 · 3 comments
Labels
🐛 Bug 🌳 Scope Hoisting Stale Ignore This issue is exempt from getting flagged as stale and autoremoved

Comments

@luca-tardito
Copy link

🐛 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
@github-actions
Copy link

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.

@github-actions github-actions bot added the Stale Inactive issues label Jul 13, 2023
@enekesabel
Copy link

@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.

@github-actions github-actions bot removed the Stale Inactive issues label Jan 12, 2024
@mischnic mischnic reopened this Jan 12, 2024
@mischnic mischnic added the Stale Ignore This issue is exempt from getting flagged as stale and autoremoved label Jan 12, 2024
@bminer
Copy link

bminer commented Jan 18, 2025

Anyone know why this is happening?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug 🌳 Scope Hoisting Stale Ignore This issue is exempt from getting flagged as stale and autoremoved
Projects
None yet
Development

No branches or pull requests

4 participants