File tree Expand file tree Collapse file tree 3 files changed +52
-0
lines changed
turbopack/crates/turbopack-tests/tests
execution/turbopack/resolving/dynamic Expand file tree Collapse file tree 3 files changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -392,6 +392,17 @@ async fn run_test_operation(prepared_test: ResolvedVc<PreparedTest>) -> Result<V
392392 . resolved_cell ( ) ,
393393 ) ;
394394
395+ let mut fallback_import_map = ImportMap :: empty ( ) ;
396+ fallback_import_map. insert_exact_alias (
397+ rcstr ! ( "fallback" ) ,
398+ ImportMapping :: External (
399+ None ,
400+ ExternalType :: EcmaScriptModule ,
401+ ExternalTraced :: Untraced ,
402+ )
403+ . resolved_cell ( ) ,
404+ ) ;
405+
395406 let remove_unused_exports = options. remove_unused_exports . unwrap_or ( true ) ;
396407
397408 let asset_context: Vc < Box < dyn AssetContext > > = Vc :: upcast ( ModuleAssetContext :: new (
@@ -435,6 +446,7 @@ async fn run_test_operation(prepared_test: ResolvedVc<PreparedTest>) -> Result<V
435446 browser : true ,
436447 module : true ,
437448 import_map : Some ( import_map. resolved_cell ( ) ) ,
449+ fallback_import_map : Some ( fallback_import_map. resolved_cell ( ) ) ,
438450 ..Default :: default ( )
439451 }
440452 . cell ( ) ,
Original file line number Diff line number Diff line change 1+ let names = [ 'cannot-resolve' ]
2+ if ( globalThis . foo != undefined ) {
3+ // ensure `<dynamic>` is part of the array
4+ names . push ( globalThis . foo )
5+ }
6+
7+ let result
8+ for ( let name of names ) {
9+ try {
10+ result = require ( name ) . Iconv
11+ return
12+ } catch { }
13+ }
14+
15+ console . log ( result )
16+
17+ it ( 'should correctly handle potentially completely dynamic requests' , ( ) => {
18+ expect ( result ) . toBeUndefined ( )
19+ } )
Original file line number Diff line number Diff line change 1+ warning - [resolve] /turbopack/crates/turbopack-tests/tests/execution/turbopack/resolving/dynamic-module/input/index.js:10:13 Module not found: Can't resolve ('cannot-resolve' | <dynamic>)
2+
3+ 6 |
4+ 7 | let result
5+ 8 | for (let name of names) {
6+ 9 | try {
7+ + v-----------v
8+ 10 + result = require(name).Iconv
9+ + ^-----------^
10+ 11 | return
11+ 12 | } catch {}
12+ 13 | }
13+ 14 |
14+
15+
16+
17+ | It was not possible to find the requested file.
18+ | Parsed request as written in source code: module "'cannot-resolve'" or dynamic
19+ | Path where resolving has started: [project]/turbopack/crates/turbopack-tests/tests/execution/turbopack/resolving/dynamic-module/input/index.js
20+ | Type of request: commonjs request
21+ |
You can’t perform that action at this time.
0 commit comments