Skip to content

Commit

Permalink
initial test case & fix (#9195)
Browse files Browse the repository at this point in the history
fix unexpected undefined from bundler
  • Loading branch information
AGawrys authored Aug 23, 2023
1 parent 702033b commit feae29e
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/bundlers/default/src/DefaultBundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ function createIdealGraph(

// Create shared bundles for splittable bundles.
if (reachable.length > config.minBundles) {
let sourceBundles = reachable.map(a => nullthrows(bundles.get(a.id)));
let sourceBundles = reachable.map(a => nullthrows(bundleRoots.get(a))[0]);
let key = reachable.map(a => a.id).join(',');
let bundleId = bundles.get(key);
let bundle;
Expand Down
27 changes: 27 additions & 0 deletions packages/core/integration-tests/test/css-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,33 @@ describe('css modules', () => {
},
]);
});

it('should not fail with many css modules', async function () {
let b = await bundle(
path.join(__dirname, '/integration/css-modules-bug/src/index.html'),
);

assertBundles(b, [
{
name: 'index.html',
assets: ['index.html'],
},
{
type: 'js',
assets: [
'button.module.css',
'main.js',
'main.module.css',
'other.module.css',
],
},
{
type: 'css',
assets: ['button.module.css', 'main.module.css', 'other.module.css'],
},
]);
});

// Forked because experimental bundler will not merge bundles of same types if they do not share all their bundlegroups
it('should handle @import in css modules', async function () {
let b = await bundle(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.buttonPrimary {
align-self: center;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!DOCTYPE html>

<html lang="en">
<script src="main.js" type="module"></script>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import * as main from "./main.module.css";
import * as other from "./other.module.css";

console.log([main.main, other.other]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.main {
composes: buttonPrimary from "./button.module.css";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.other {
composes: buttonPrimary from "./button.module.css";
}
Empty file.

0 comments on commit feae29e

Please sign in to comment.