-
-
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
Runtime error when re-exporting empty module #6361
Comments
Hey @matt-tingen, I'm also going through this when exporting only type... Link to repo: https://github.com/oeduardoal/error-parcel-empty-module |
But here, Its occurring in version "parcel": "2.0.0-beta.3.1" |
Interestingly, my repro appears to be fixed in nightly 701+, as is
This error does not occur when commenting out an The SIGILL can also be observed in oeduardoal's repro when updating parcel dependencies to the latest nightlies. As of this posting:
|
I think the typescript types reexport issue should be fixed by #6414. Try a recent nightly and see if it works for you. I'm not sure what the v8 issue you're seeing is. Are you sure it's related? |
That will be fixed soon: kriszyp/lmdb-js#51 |
The hoisting issue does appear to be resolved. It seems that the empty modules can sometimes trigger the V8 error, but don't necessarily do so. However, since that error is tracked elsewhere, I'll go ahead and close this issue. Thanks for all your work on parcel! |
I'm reopening this because the issue still exists with empty modules, but has more specific preconditions now. With the I updated my repro to reflect the new preconditions as best I could figure out. It seems to require a peer re-export of the empty re-export to transitively re-export from another package. |
Unfortunately, I don't think there's much we can do here. If you add |
Thanks for the update, Devon. Good to know there's a path forward; I've let chakra know. For my own edification, do you mind clarifying why parcel has to treat such a file as CJS? |
Right now, empty modules are treated the same as a module with the following: module.exports = {}; This is required for compatibility with CommonJS. @mischnic might know if we could special case this in symbol propagation, but in general it gets complicated. |
Minimal reproduction: // index.js
import {mergeWith} from './other2';
console.log(mergeWith);
// other2.js
export * from './other';
export * from './empty';
// other.js
export { default as mergeWith } from "./mergeWith";
// mergeWith.js
module.exports = function mergeWith() {}
// empty.js The combination of CJS module that assigns to This results in the following used symbols:
All other files have no used symbols. This results in the following output: (function () {
var $cd23135fd8be48a6$exports = {};
$cd23135fd8be48a6$exports = function mergeWith() {
};
var $3b0fc8b297effe95$exports = {};
console.log($ab990769c98d8a99$exports.mergeWith);
})(); This errors with @mischnic do you think symbol propagation should somehow mark |
Another smaller example: // index.js
import { b } from "./other2";
console.log(b);
// other2.js
export * from "./other";
export * from "./empty";
// other.js
module.exports = { a: 1 };
// empty.js
module.exports = { b: 2 }; |
🐛 bug report
When using
parcel build
,export * from './empty-module'
in an esm dependency will result in a runtime error.The error does not manifest when using
parcel serve
.🎛 Configuration (.babelrc, package.json, cli command)
No parcel config, just
parcel build src/index.html
🤔 Expected Behavior
No error
😯 Current Behavior
Runtime error such as
Uncaught ReferenceError: $fd1dd7bd163658327eae64fa2f71c5d2$exports is not defined
💁 Possible Solution
Not sure, but if you think this would be an approachable first issue, I'd be happy to take a look.
🔦 Context
I ran into this with
@chakra-ui/utils
which hasexport * from './types'
wheretypes.ts
is a file which only exports types so it compiles into an empty file. A repro using this chakra can be found in the repro repo.As far as I can tell from the spec, empty modules are valid. I could be misunderstanding that, though.
💻 Code Sample
Repro repo
The additional
foo
import seems to be needed. Presumably this to prevent DCE.The package boundary also appears to be necessary as far as I could tell.
🌍 Your Environment
2.0.0-nightly.688
v14.15.0
1.22.10
The text was updated successfully, but these errors were encountered: