Skip to content

Commit fbcd624

Browse files
committed
Fix MDX inline assets in static RSCs
1 parent 86bddb4 commit fbcd624

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

packages/core/core/src/UncommittedAsset.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,11 @@ export default class UncommittedAsset {
364364
filePath: this.value.filePath,
365365
type: result.type,
366366
bundleBehavior:
367-
result.bundleBehavior ??
368-
(this.value.bundleBehavior == null
369-
? null
370-
: BundleBehaviorNames[this.value.bundleBehavior]),
367+
result.bundleBehavior === undefined
368+
? this.value.bundleBehavior == null
369+
? null
370+
: BundleBehaviorNames[this.value.bundleBehavior]
371+
: result.bundleBehavior,
371372
isBundleSplittable:
372373
result.isBundleSplittable ?? this.value.isBundleSplittable,
373374
isSource: this.value.isSource,

packages/core/integration-tests/test/react-ssg.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ describe('react static', function () {
196196
197197
Yo.
198198
199+
~~~tsx render
200+
<div>Hello</div>
201+
~~~
202+
199203
another.mdx:
200204
import {Layout} from './Layout';
201205
export default Layout;
@@ -247,6 +251,7 @@ describe('react static', function () {
247251
assert(
248252
output.includes('<ul><li>Testing<ul><li>Sub title</li></ul></li></ul>'),
249253
);
254+
assert(output.includes('<div>Hello</div'));
250255

251256
output = await overlayFS.readFile(b.getBundles()[1].filePath, 'utf8');
252257
assert(output.includes('<title>Another page</title>'));
@@ -382,7 +387,7 @@ describe('react static', function () {
382387
export function Client() {
383388
return <Dynamic />;
384389
}
385-
390+
386391
dynamic.jsx:
387392
import './client.css';
388393
export default function Dynamic() {

packages/packagers/react-static/src/ReactStaticPackager.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,12 @@ function runModule(
509509
}
510510

511511
function getCacheKey(asset: Asset) {
512-
return asset.filePath + '#' + asset.env.context;
512+
return (
513+
asset.filePath +
514+
'#' +
515+
asset.env.context +
516+
(asset.uniqueKey ? '-' + asset.uniqueKey : '')
517+
);
513518
}
514519

515520
function getSpecifier(dep: Dependency) {

packages/transformers/js/src/JSTransformer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,7 @@ export default (new Transformer({
536536
content: a.content,
537537
map,
538538
uniqueKey: k,
539+
bundleBehavior: null,
539540
});
540541

541542
asset.addDependency({
@@ -738,6 +739,7 @@ export default (new Transformer({
738739
content: mdxAsset.code,
739740
map,
740741
uniqueKey: 'mdx-' + i,
742+
bundleBehavior: null,
741743
});
742744
}
743745
}

0 commit comments

Comments
 (0)