Unverified Commit cbf12d18 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

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
parent b6ff1f60
...@@ -8,7 +8,10 @@ import replacedValue from '../data-with-placeholder.js' with { turbopackLoader: ...@@ -8,7 +8,10 @@ import replacedValue from '../data-with-placeholder.js' with { turbopackLoader:
import rawTextViaModuleType from '../data2.txt' with { turbopackLoader: '../node_modules/test-raw-loader/index.js', turbopackModuleType: 'ecmascript' } import rawTextViaModuleType from '../data2.txt' with { turbopackLoader: '../node_modules/test-raw-loader/index.js', turbopackModuleType: 'ecmascript' }
// Import a non-.json file and treat it as JSON via turbopackModuleType // Import a non-.json file and treat it as JSON via turbopackModuleType
import jsonData from '../data.jsonlike' with { turbopackLoader: 'test-identity-loader', turbopackModuleType: 'json' } import jsonData from '../data.jsonlike' with { turbopackLoader: 'test-identity-loader', turbopackModuleType: 'json' }
// Normal rules should still work at the same time
import jsonData2 from '../data.jsonlike2'
console.log(jsonData, jsonData2)
export default function Page() { export default function Page() {
return ( return (
<div> <div>
...@@ -16,6 +19,7 @@ export default function Page() { ...@@ -16,6 +19,7 @@ export default function Page() {
<p id="replaced">{replacedValue}</p> <p id="replaced">{replacedValue}</p>
<p id="module-type">{rawTextViaModuleType}</p> <p id="module-type">{rawTextViaModuleType}</p>
<p id="json-type">{jsonData.greeting}</p> <p id="json-type">{jsonData.greeting}</p>
<p id="json-type-2">{jsonData2.greeting}</p>
</div> </div>
) )
} }
/** /**
* @type {import('next').NextConfig} * @type {import('next').NextConfig}
*/ */
const nextConfig = {} const nextConfig = {
turbopack: {
rules: {
'*.jsonlike2': {
loaders: ['test-identity-loader'],
as: '*.json',
},
},
},
}
module.exports = nextConfig module.exports = nextConfig
...@@ -31,4 +31,9 @@ describe('turbopack-import-assertions-use', () => { ...@@ -31,4 +31,9 @@ describe('turbopack-import-assertions-use', () => {
const $ = await next.render$('/') const $ = await next.render$('/')
expect($('#json-type').text()).toBe('Hello from JSON module type') expect($('#json-type').text()).toBe('Hello from JSON module type')
}) })
it('should apply identity with loader rules', async () => {
const $ = await next.render$('/')
expect($('#json-type-2').text()).toBe('Hello from JSON module type 2')
})
}) })
...@@ -716,7 +716,7 @@ async fn process_default_internal( ...@@ -716,7 +716,7 @@ async fn process_default_internal(
*execution_context, *execution_context,
Some(import_map), Some(import_map),
None, None,
Layer::new(rcstr!("turbopack_use_loaders")), Layer::new(rcstr!("webpack_loaders")),
false, false,
) )
.to_resolved() .to_resolved()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment