MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

add tests for importing

+79
+1
tests/import_dynamic_filename_capture_child.mjs
··· 1 + export const childFilename = import.meta.filename;
+4
tests/import_dynamic_filename_capture_exporter.mjs
··· 1 + export async function loadChildLater() { 2 + const child = await import('./import_dynamic_filename_capture_child.mjs'); 3 + return child.childFilename; 4 + }
+19
tests/import_dynamic_filename_capture_parent.mjs
··· 1 + function assert(condition, message) { 2 + if (!condition) throw new Error(message); 3 + } 4 + 5 + const topFilename = import.meta.filename; 6 + 7 + async function loadChild() { 8 + return await import('./import_dynamic_filename_capture_child.mjs'); 9 + } 10 + 11 + const child = await loadChild(); 12 + 13 + assert(import.meta.filename === topFilename, 'parent import.meta.filename drifted'); 14 + assert( 15 + child.childFilename.endsWith('/tests/import_dynamic_filename_capture_child.mjs'), 16 + `dynamic import resolved from wrong base: ${child.childFilename}` 17 + ); 18 + 19 + console.log(`import.dynamic.filename.capture:${topFilename}`);
+14
tests/import_dynamic_filename_capture_runner.mjs
··· 1 + function assert(condition, message) { 2 + if (!condition) throw new Error(message); 3 + } 4 + 5 + import { loadChildLater } from './import_dynamic_filename_capture_exporter.mjs'; 6 + 7 + const childFilename = await loadChildLater(); 8 + 9 + assert( 10 + childFilename.endsWith('/tests/import_dynamic_filename_capture_child.mjs'), 11 + `late dynamic import resolved from wrong base: ${childFilename}` 12 + ); 13 + 14 + console.log(`import.dynamic.filename.late:${childFilename}`);
+14
tests/import_dynamic_rsc_path_runner.mjs
··· 1 + function assert(condition, message) { 2 + if (!condition) throw new Error(message); 3 + } 4 + 5 + import { loadRscIndexLater } from './ssr/index.js'; 6 + 7 + const filename = await loadRscIndexLater(); 8 + 9 + assert( 10 + filename.endsWith('/tests/rsc/index.js'), 11 + `late dynamic import resolved from wrong base: ${filename}` 12 + ); 13 + 14 + console.log(`import.dynamic.rsc.path:${filename}`);
+22
tests/import_meta_filename_capture.mjs
··· 1 + function assert(condition, message) { 2 + if (!condition) throw new Error(message); 3 + } 4 + 5 + const topFilename = import.meta.filename; 6 + 7 + function nestedFilename() { 8 + return import.meta.filename; 9 + } 10 + 11 + async function asyncFilename() { 12 + await 0; 13 + return import.meta.filename; 14 + } 15 + 16 + const nested = nestedFilename(); 17 + const asyncValue = await asyncFilename(); 18 + 19 + assert(nested === topFilename, `nested import.meta.filename drifted: ${nested} !== ${topFilename}`); 20 + assert(asyncValue === topFilename, `async import.meta.filename drifted: ${asyncValue} !== ${topFilename}`); 21 + 22 + console.log(`import.meta.filename.capture:${topFilename}`);
+1
tests/rsc/index.js
··· 1 + export const marker = import.meta.filename;
+4
tests/ssr/index.js
··· 1 + export async function loadRscIndexLater() { 2 + const mod = await import('../rsc/index.js'); 3 + return mod.marker; 4 + }