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

Fix error masking when errors occur in the bundle graph request #340

Merged
merged 4 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/stupid-moons-reflect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@atlaspack/core': patch
---

Ensure bundle graph request errors show up correctly
15 changes: 8 additions & 7 deletions packages/core/core/src/requests/BundleGraphRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,13 +440,14 @@ class BundlerRunner {
}),
});
} finally {
invariant(internalBundleGraph != null); // ensures the graph was created
await dumpGraphToGraphViz(
// $FlowFixMe[incompatible-call]
internalBundleGraph._graph,
'after_bundle',
bundleGraphEdgeTypes,
);
if (internalBundleGraph != null) {
await dumpGraphToGraphViz(
// $FlowFixMe[incompatible-call]
internalBundleGraph._graph,
'after_bundle',
bundleGraphEdgeTypes,
);
}
}

let changedRuntimes = new Map();
Expand Down
36 changes: 36 additions & 0 deletions packages/core/integration-tests/test/scope-hoisting.js
Original file line number Diff line number Diff line change
Expand Up @@ -6455,4 +6455,40 @@ describe('scope hoisting', function () {
},
]);
});

// This is currently failing due to dependency.sourceAssetId becoming stale
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it started failing with this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I discovered it from a support request. I'm making a ticket to track the fix separately but thought it was worth committing the repro

// after Asset.type changing (e.g. ts -> js).
it.skip('should handle multiple re-export rename combinations', async function () {
await fsFixture(overlayFS, __dirname)`
stuff
one.ts:
export const one = 'one';
two.ts:
export {one as exportOne} from './one';
other.ts:
export const other = 'other';
library.ts:
export * from './two';
import {other} from './other';
export const exportOther = other;
index.ts:
import {exportOne, exportOther} from './library';
console.log(exportOne, exportOther);
index.html:
<script type="module" src="./index.ts"></script>
package.json:
{"sideEffects": false}
yarn.lock:`;

let b = await bundle([path.join(__dirname, 'stuff/index.html')], {
mode: 'production',
defaultTargetOptions: {
shouldScopeHoist: true,
outputFormat: 'esmodule',
},
inputFS: overlayFS,
});

await run(b);
});
});