11import { emptyEnv } from "../env/Env.ts"
22import { evaluate } from "../evaluate/evaluate.ts"
3- import { modDefine , modFind , modResolve } from "../mod/index.ts"
3+ import { modDefine } from "../mod/index.ts"
44import type { Mod } from "../mod/Mod.ts"
5- import type { ImportEntry , Stmt } from "../stmt/Stmt.ts"
6- import { globalLoadedMods } from "./globalLoadedMods.ts"
7- import { run } from "./run.ts"
5+ import type { Stmt } from "../stmt/Stmt.ts"
86
97export function handleDefine ( mod : Mod , stmt : Stmt ) : void {
108 if ( stmt . kind === "Define" ) {
@@ -22,37 +20,4 @@ export function handleDefine(mod: Mod, stmt: Stmt): void {
2220
2321 return
2422 }
25-
26- if ( stmt . kind === "Import" ) {
27- for ( const entry of stmt . entries ) {
28- importOne ( mod , stmt . path , entry )
29- }
30-
31- return
32- }
33- }
34-
35- function importOne ( mod : Mod , path : string , entry : ImportEntry ) : void {
36- const url = modResolve ( mod , path )
37- if ( url . href === mod . url . href ) {
38- throw new Error ( `I can not circular import: ${ path } ` )
39- }
40-
41- const found = globalLoadedMods . get ( url . href )
42- if ( found === undefined ) {
43- throw new Error ( `Mod is not loaded: ${ path } ` )
44- }
45-
46- run ( found . mod )
47-
48- const { name, rename } = entry
49-
50- const def = modFind ( found . mod , name )
51- if ( def === undefined ) {
52- throw new Error (
53- `I can not import undefined name: ${ name } , from path: ${ path } ` ,
54- )
55- }
56-
57- modDefine ( mod , rename || name , def )
5823}
0 commit comments