File tree Expand file tree Collapse file tree 4 files changed +7
-7
lines changed Expand file tree Collapse file tree 4 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ lp.parseTopLevel = function() {
10
10
while ( this . tok . type !== tt . eof ) node . body . push ( this . parseStatement ( ) )
11
11
this . toks . adaptDirectivePrologue ( node . body )
12
12
this . last = this . tok
13
- node . sourceType = this . options . sourceType
13
+ node . sourceType = this . options . sourceType === "commonjs" ? "script" : this . options . sourceType
14
14
return this . finishNode ( node , "Program" )
15
15
}
16
16
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ export interface Literal extends Node {
38
38
export interface Program extends Node {
39
39
type : "Program"
40
40
body : Array < Statement | ModuleDeclaration >
41
- sourceType : "script" | "module" | "commonjs"
41
+ sourceType : "script" | "module"
42
42
}
43
43
44
44
export interface Function extends Node {
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ pp.parseTopLevel = function(node) {
27
27
this . raiseRecoverable ( this . undefinedExports [ name ] . start , `Export '${ name } ' is not defined` )
28
28
this . adaptDirectivePrologue ( node . body )
29
29
this . next ( )
30
- node . sourceType = this . options . sourceType
30
+ node . sourceType = this . options . sourceType === "commonjs" ? "script" : this . options . sourceType
31
31
return this . finishNode ( node , "Program" )
32
32
}
33
33
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ test("using x = resource;", {
21
21
} ] ,
22
22
kind : "using"
23
23
} ] ,
24
- sourceType : "commonjs "
24
+ sourceType : "script "
25
25
} , { ecmaVersion : 17 , sourceType : "commonjs" } ) ;
26
26
27
27
// Top-level new.target with commonjs
@@ -35,7 +35,7 @@ test("new.target", {
35
35
property : { type : "Identifier" , name : "target" }
36
36
}
37
37
} ] ,
38
- sourceType : "commonjs "
38
+ sourceType : "script "
39
39
} , { ecmaVersion : 6 , sourceType : "commonjs" } ) ;
40
40
41
41
// new.target at top-level scope with commonjs
@@ -61,7 +61,7 @@ test("let y = () => new.target", {
61
61
} ] ,
62
62
kind : "let"
63
63
} ] ,
64
- sourceType : "commonjs "
64
+ sourceType : "script "
65
65
} , { ecmaVersion : 6 , sourceType : "commonjs" } ) ;
66
66
67
67
// Top-level return statement with commonjs
@@ -82,7 +82,7 @@ test("return {} / 2", {
82
82
operator : "/"
83
83
}
84
84
} ] ,
85
- sourceType : "commonjs "
85
+ sourceType : "script "
86
86
} , { sourceType : "commonjs" } ) ;
87
87
88
88
// Illegal return statement with commonjs
You can’t perform that action at this time.
0 commit comments