Skip to content

Commit 27886d3

Browse files
mischnicijjk
authored andcommitted
Turbopack: fix webpack loader runner layer (#91727)
Otherwise you get a `Dependency tracking is disabled` / infinite loop when trying to use both turbopack.rules.loader and turbopackLoader at the same time
1 parent 88fc430 commit 27886d3

5 files changed

Lines changed: 21 additions & 2 deletions

File tree

test/development/app-dir/turbopack-import-assertions-use/app/page.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@ import replacedValue from '../data-with-placeholder.js' with { turbopackLoader:
88
import rawTextViaModuleType from '../data2.txt' with { turbopackLoader: '../node_modules/test-raw-loader/index.js', turbopackModuleType: 'ecmascript' }
99
// Import a non-.json file and treat it as JSON via turbopackModuleType
1010
import jsonData from '../data.jsonlike' with { turbopackLoader: 'test-identity-loader', turbopackModuleType: 'json' }
11+
// Normal rules should still work at the same time
12+
import jsonData2 from '../data.jsonlike2'
1113

14+
console.log(jsonData, jsonData2)
1215
export default function Page() {
1316
return (
1417
<div>
1518
<p id="raw">{rawText}</p>
1619
<p id="replaced">{replacedValue}</p>
1720
<p id="module-type">{rawTextViaModuleType}</p>
1821
<p id="json-type">{jsonData.greeting}</p>
22+
<p id="json-type-2">{jsonData2.greeting}</p>
1923
</div>
2024
)
2125
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"greeting": "Hello from JSON module type 2"}
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
/**
22
* @type {import('next').NextConfig}
33
*/
4-
const nextConfig = {}
4+
const nextConfig = {
5+
turbopack: {
6+
rules: {
7+
'*.jsonlike2': {
8+
loaders: ['test-identity-loader'],
9+
as: '*.json',
10+
},
11+
},
12+
},
13+
}
514

615
module.exports = nextConfig

test/development/app-dir/turbopack-import-assertions-use/turbopack-import-assertions-use.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,9 @@ describe('turbopack-import-assertions-use', () => {
3131
const $ = await next.render$('/')
3232
expect($('#json-type').text()).toBe('Hello from JSON module type')
3333
})
34+
35+
it('should apply identity with loader rules', async () => {
36+
const $ = await next.render$('/')
37+
expect($('#json-type-2').text()).toBe('Hello from JSON module type 2')
38+
})
3439
})

turbopack/crates/turbopack/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ async fn process_default_internal(
716716
*execution_context,
717717
Some(import_map),
718718
None,
719-
Layer::new(rcstr!("turbopack_use_loaders")),
719+
Layer::new(rcstr!("webpack_loaders")),
720720
false,
721721
)
722722
.to_resolved()

0 commit comments

Comments
 (0)