Skip to content

Commit bad04d0

Browse files
committed
Turbopack: improve module evaluation name
1 parent 642ae3e commit bad04d0

File tree

16 files changed

+34
-48
lines changed

16 files changed

+34
-48
lines changed

test/development/middleware-errors/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ describe('middleware - development errors', () => {
297297
isTurbopack
298298
? '\n ⨯ Error: booooom!' +
299299
// TODO(veil): Should be sourcemapped
300-
'\n at __TURBOPACK__module__evaluation__ (middleware.js:3:13)'
300+
'\n at module evaluation (middleware.js:3:13)'
301301
: '\n ⨯ Error: booooom!' +
302302
// TODO: Should be anonymous method without a method name
303303
'\n at <unknown> (middleware.js:3)' +

test/e2e/app-dir/cache-components-errors/cache-components-errors.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2758,7 +2758,7 @@ describe('Cache Components Errors', () => {
27582758
if (isDebugPrerender) {
27592759
expect(output).toMatchInlineSnapshot(`
27602760
"Error: "use cache: private" must not be used within \`unstable_cache()\`.
2761-
at __TURBOPACK__module__evaluation__ (bundler:///app/use-cache-private-in-unstable-cache/page.tsx:21:38)
2761+
at module evaluation (bundler:///app/use-cache-private-in-unstable-cache/page.tsx:21:38)
27622762
at a (<next-dist-dir>)
27632763
19 | }
27642764
20 |
@@ -2776,7 +2776,7 @@ describe('Cache Components Errors', () => {
27762776
} else {
27772777
expect(output).toMatchInlineSnapshot(`
27782778
"Error: "use cache: private" must not be used within \`unstable_cache()\`.
2779-
at __TURBOPACK__module__evaluation__ (bundler:///app/use-cache-private-in-unstable-cache/page.tsx:21:38)
2779+
at module evaluation (bundler:///app/use-cache-private-in-unstable-cache/page.tsx:21:38)
27802780
19 | }
27812781
20 |
27822782
> 21 | const getCachedData = unstable_cache(async () => {
@@ -2930,7 +2930,7 @@ describe('Cache Components Errors', () => {
29302930
if (isDebugPrerender) {
29312931
expect(output).toMatchInlineSnapshot(`
29322932
"Error: "use cache: private" must not be used within "use cache". It can only be nested inside of another "use cache: private".
2933-
at __TURBOPACK__module__evaluation__ (bundler:///app/use-cache-private-in-use-cache/page.tsx:15:1)
2933+
at module evaluation (bundler:///app/use-cache-private-in-use-cache/page.tsx:15:1)
29342934
at a (<next-dist-dir>)
29352935
13 | }
29362936
14 |
@@ -2940,7 +2940,7 @@ describe('Cache Components Errors', () => {
29402940
17 |
29412941
18 | return <p>Private</p>
29422942
Error: "use cache: private" must not be used within "use cache". It can only be nested inside of another "use cache: private".
2943-
at __TURBOPACK__module__evaluation__ (bundler:///app/use-cache-private-in-use-cache/page.tsx:15:1)
2943+
at module evaluation (bundler:///app/use-cache-private-in-use-cache/page.tsx:15:1)
29442944
at b (<next-dist-dir>)
29452945
13 | }
29462946
14 |
@@ -2958,7 +2958,7 @@ describe('Cache Components Errors', () => {
29582958
} else {
29592959
expect(output).toMatchInlineSnapshot(`
29602960
"Error: "use cache: private" must not be used within "use cache". It can only be nested inside of another "use cache: private".
2961-
at __TURBOPACK__module__evaluation__ (bundler:///app/use-cache-private-in-use-cache/page.tsx:15:1)
2961+
at module evaluation (bundler:///app/use-cache-private-in-use-cache/page.tsx:15:1)
29622962
13 | }
29632963
14 |
29642964
> 15 | async function Private() {
@@ -2967,7 +2967,7 @@ describe('Cache Components Errors', () => {
29672967
17 |
29682968
18 | return <p>Private</p>
29692969
Error: "use cache: private" must not be used within "use cache". It can only be nested inside of another "use cache: private".
2970-
at __TURBOPACK__module__evaluation__ (bundler:///app/use-cache-private-in-use-cache/page.tsx:15:1)
2970+
at module evaluation (bundler:///app/use-cache-private-in-use-cache/page.tsx:15:1)
29712971
13 | }
29722972
14 |
29732973
> 15 | async function Private() {

test/e2e/app-dir/server-source-maps/server-source-maps.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -445,10 +445,10 @@ describe('app-dir - server source maps', () => {
445445
'' +
446446
'\nError: module-evaluation' +
447447
// TODO(veil): Should map to no name like you'd get with native stacks without a bundler.
448-
'\n at __TURBOPACK__module__evaluation__ (app/module-evaluation/module.js:1:22)' +
448+
'\n at module evaluation (app/module-evaluation/module.js:1:22)' +
449449
// TODO(veil): Added frames from bundler should be sourcemapped (https://linear.app/vercel/issue/NDX-509/)
450-
'\n at __TURBOPACK__module__evaluation__ (app/module-evaluation/page.js:1:1)' +
451-
'\n at __TURBOPACK__module__evaluation__ (.next'
450+
'\n at module evaluation (app/module-evaluation/page.js:1:1)' +
451+
'\n at module evaluation (.next'
452452
)
453453
} else {
454454
expect(cliOutput).toContain(
@@ -536,7 +536,7 @@ describe('app-dir - server source maps', () => {
536536
'' +
537537
'\nError: module-evaluation' +
538538
// TODO(veil): Turbopack internals. Feel free to update. Tracked in https://linear.app/vercel/issue/NEXT-4362
539-
'\n at __TURBOPACK__module__evaluation__ (bundler:///app/module-evaluation/module.js:1:22)'
539+
'\n at module evaluation (bundler:///app/module-evaluation/module.js:1:22)'
540540
)
541541
expect(normalizeCliOutput(next.cliOutput)).toContain(
542542
'' +

test/e2e/app-dir/use-cache-close-over-function/use-cache-close-over-function.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ describe('use-cache-close-over-function', () => {
9999
'\n [function fn]' +
100100
'\n ^^^^^^^^^^^' +
101101
'\n at createCachedFn (app/server/page.tsx:6:3)' +
102-
'\n at __TURBOPACK__module__evaluation__ (app/server/page.tsx:12:24)'
102+
'\n at module evaluation (app/server/page.tsx:12:24)'
103103
: '' +
104104
'Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server". Or maybe you meant to call this function rather than return it.' +
105105
'\n [function fn]' +

test/e2e/app-dir/use-cache-hanging-inputs/use-cache-hanging-inputs.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe('use-cache-hanging-inputs', () => {
5959
`)
6060

6161
expect(cliOutput).toContain(`Error: ${expectedTimeoutErrorMessage}
62-
at __TURBOPACK__module__evaluation__`)
62+
at module evaluation`)
6363
} else {
6464
expect(errorSource).toMatchInlineSnapshot(`
6565
"app/uncached-promise/page.tsx (10:13) @ eval
@@ -113,7 +113,7 @@ describe('use-cache-hanging-inputs', () => {
113113
`)
114114

115115
expect(cliOutput).toContain(`Error: ${expectedTimeoutErrorMessage}
116-
at __TURBOPACK__module__evaluation__`)
116+
at module evaluation`)
117117
} else {
118118
expect(errorSource).toMatchInlineSnapshot(`
119119
"app/uncached-promise-nested/page.tsx (16:1) @ eval
@@ -168,7 +168,7 @@ describe('use-cache-hanging-inputs', () => {
168168
`)
169169

170170
expect(cliOutput).toContain(`Error: ${expectedTimeoutErrorMessage}
171-
at __TURBOPACK__module__evaluation__`)
171+
at module evaluation`)
172172
} else {
173173
expect(errorSource).toMatchInlineSnapshot(`
174174
"app/bound-args/page.tsx (13:15) @ eval

turbopack/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,6 @@ type ContextConstructor<M> = {
719719
function applyModuleFactoryName(factory: Function) {
720720
// Give the module factory a nice name to improve stack traces.
721721
Object.defineProperty(factory, 'name', {
722-
value: '__TURBOPACK__module__evaluation__',
722+
value: 'module evaluation',
723723
})
724724
}

turbopack/crates/turbopack-ecmascript-runtime/src/browser_runtime.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use turbopack_core::{
99
context::AssetContext,
1010
environment::{ChunkLoading, Environment},
1111
};
12-
use turbopack_ecmascript::{magic_identifier, utils::StringifyJs};
12+
use turbopack_ecmascript::utils::StringifyJs;
1313

1414
use crate::{RuntimeType, asset_context::get_runtime_asset_context, embed_js::embed_static_code};
1515

@@ -35,12 +35,6 @@ pub async fn get_browser_runtime_code(
3535
match runtime_type {
3636
RuntimeType::Production => runtime_base_code.push("browser/runtime/base/build-base.ts"),
3737
RuntimeType::Development => {
38-
debug_assert!(
39-
// The dev runtime makes this assumption. If that's no longer true, we need to
40-
// update the runtime code.
41-
magic_identifier::mangle("module evaluation").as_str()
42-
== "__TURBOPACK__module__evaluation__"
43-
);
4438
runtime_base_code.push("browser/runtime/base/dev-base.ts");
4539
}
4640
#[cfg(feature = "test")]

turbopack/crates/turbopack-ecmascript/src/magic_identifier.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,6 @@ mod tests {
155155

156156
#[test]
157157
fn test_encode() {
158-
assert_eq!(
159-
mangle("module evaluation"),
160-
"__TURBOPACK__module__evaluation__"
161-
);
162158
assert_eq!(mangle("Hello World"), "__TURBOPACK__Hello__World__");
163159
assert_eq!(mangle("Hello_World"), "__TURBOPACK__Hello_World__");
164160
assert_eq!(mangle("Hello__World"), "__TURBOPACK__Hello_$5f$World__");
@@ -180,10 +176,6 @@ mod tests {
180176

181177
#[test]
182178
fn test_decode() {
183-
assert_eq!(
184-
unmangle("__TURBOPACK__module__evaluation__"),
185-
"module evaluation"
186-
);
187179
assert_eq!(unmangle("__TURBOPACK__Hello__World__"), "Hello World");
188180
assert_eq!(unmangle("__TURBOPACK__Hello_World__"), "Hello_World");
189181
assert_eq!(unmangle("__TURBOPACK__Hello_$5f$World__"), "Hello__World");

turbopack/crates/turbopack-tests/tests/snapshot/debug-ids/browser/output/aaf3a_crates_turbopack-tests_tests_snapshot_debug-ids_browser_input_index_0151fefb.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

turbopack/crates/turbopack-tests/tests/snapshot/debug-ids/browser/output/ba425_crates_turbopack-tests_tests_snapshot_debug-ids_browser_input_index_0151fefb.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)