@@ -5,7 +5,7 @@ import { getOptions, interpolateName, OptionObject } from "loader-utils";
5
5
import { validate } from "schema-utils" ;
6
6
import { Schema } from "schema-utils/declarations/validate" ;
7
7
import { createCompilerHost } from "./compiler-host" ;
8
- import { mapAscOptionsToArgs } from "./options" ;
8
+ import { mapAscOptionsToArgs , Options } from "./options" ;
9
9
import { AssemblyScriptError } from "./error" ;
10
10
import schema from "./schema.json" ;
11
11
import { addErrorToModule , addWarningToModule } from "./webpack" ;
@@ -43,11 +43,15 @@ function loader(this: any, buffer: Buffer) {
43
43
...userAscOptions
44
44
} = options as LoaderOptions & CompilerOptions ;
45
45
46
- const ascOptions = {
46
+ const ascOptions : Options = {
47
47
// default options
48
48
// when user imports wasm with webassembly type, it's not possible to pass env
49
49
runtime : module . type ?. startsWith ( "webassembly" ) ? "stub" : "incremental" ,
50
50
exportRuntime : ! module . type ?. startsWith ( "webassembly" ) ,
51
+ debug : this . mode === "development" ,
52
+ optimizeLevel : 3 ,
53
+ shrinkLevel : 1 ,
54
+ noAssert : this . mode === "production" ,
51
55
// user options
52
56
...userAscOptions ,
53
57
} ;
@@ -91,6 +95,10 @@ function loader(this: any, buffer: Buffer) {
91
95
92
96
const host = createCompilerHost ( this ) ;
93
97
98
+ if ( shouldGenerateSourceMap ) {
99
+ ascOptions . sourceMap = true ;
100
+ }
101
+
94
102
const args = [
95
103
path . basename ( this . resourcePath ) ,
96
104
"--baseDir" ,
@@ -99,9 +107,6 @@ function loader(this: any, buffer: Buffer) {
99
107
outFileName ,
100
108
...mapAscOptionsToArgs ( ascOptions ) ,
101
109
] ;
102
- if ( shouldGenerateSourceMap ) {
103
- args . push ( "--sourceMap" , "--debug" ) ;
104
- }
105
110
if ( bind && name . endsWith ( ".wasm" ) ) {
106
111
// add required by as-bind file to compilation
107
112
args . unshift ( require . resolve ( "as-bind/lib/assembly/as-bind.ts" ) ) ;
0 commit comments