-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix extra swc optimizer applied to node_modules in browser layer (#62051
) Disable swc transform optimizer for node_modules in browser layer of app router bundles Fixes #61858 Fixes #60644 Fixes #60920 Fixes #61740 Closes NEXT-2418 In browser there could be not only one runtime, it could have both js worker and browser. In js worker the `typeof window` is not as same as in browser, so disabling the swc optimizer which will replace the code. Leave the condition as it as.
- Loading branch information
Showing
8 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use client' | ||
import { useState } from 'react' | ||
|
||
export default function Home() { | ||
const [state, setState] = useState('default') | ||
return ( | ||
<div> | ||
<button | ||
onClick={() => { | ||
const worker = new Worker(new URL('./worker', import.meta.url)) | ||
worker.addEventListener('message', (event) => { | ||
setState(event.data) | ||
}) | ||
}} | ||
> | ||
Get web worker data | ||
</button> | ||
<p>Worker state: </p> | ||
<p id="worker-state">{state}</p> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { value } from 'browser-module' | ||
|
||
self.postMessage('worker.js:' + value) |
4 changes: 4 additions & 0 deletions
4
test/e2e/app-dir/app-external/node_modules_bak/browser-module/browser.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
'use client' | ||
|
||
export const value = | ||
'browser-module/' + (typeof window !== 'undefined' ? 'browser' : 'other') |
1 change: 1 addition & 0 deletions
1
test/e2e/app-dir/app-external/node_modules_bak/browser-module/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const value = 'browser-module/index' |
7 changes: 7 additions & 0 deletions
7
test/e2e/app-dir/app-external/node_modules_bak/browser-module/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "module", | ||
"exports": { | ||
"browser": "./browser.js", | ||
"default": "./index.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters