@@ -22,15 +22,15 @@ try {
22
22
23
23
// Common constants
24
24
25
- const VERSION = typeof BUNDLE_VERSION === "string" ? BUNDLE_VERSION : require ( "../package.json" ) . version + ( isDev ? "-dev" : "" ) ;
26
- const OPTIONS = require ( "./asc.json" ) ;
25
+ const isBundle = typeof BUNDLE_VERSION === "string" ;
26
+ const VERSION = exports . version = isBundle ? BUNDLE_VERSION : require ( "../package.json" ) . version + ( isDev ? "-dev" : "" ) ;
27
+ const OPTIONS = exports . options = require ( "./asc.json" ) ;
27
28
const SOURCEMAP_ROOT = "assemblyscript:///" ;
28
29
const LIBRARY_PREFIX = assemblyscript . LIBRARY_PREFIX ;
29
- const DEFAULT_OPTIMIZE_LEVEL = 2 ;
30
- const DEFAULT_SHRINK_LEVEL = 1 ;
31
- const LIBRARY = typeof BUNDLE_LIBRARY !== "undefined" ? BUNDLE_LIBRARY : { } ;
32
-
33
- exports . VERSION = VERSION ;
30
+ const DEFAULT_OPTIMIZE_LEVEL = exports . defaultOptimizeLevel = 2 ;
31
+ const DEFAULT_SHRINK_LEVEL = exports . defaultShrinkLevel = 1 ;
32
+ const LIBRARY_FILES = exports . libraryFiles = isBundle ? BUNDLE_LIBRARY : { } ;
33
+ const DEFINITION_FILES = exports . definitionFiles = isBundle ? BUNDLE_DEFINITIONS : { } ;
34
34
35
35
function main ( argv , options , callback ) {
36
36
if ( typeof options === "function" ) {
@@ -151,8 +151,8 @@ function main(argv, options, callback) {
151
151
// Load library file if explicitly requested
152
152
if ( sourcePath . startsWith ( LIBRARY_PREFIX ) ) {
153
153
for ( let i = 0 , k = libDirs . length ; i < k ; ++ i ) {
154
- if ( LIBRARY . hasOwnProperty ( sourcePath ) )
155
- sourceText = LIBRARY [ sourcePath ] ;
154
+ if ( LIBRARY_FILES . hasOwnProperty ( sourcePath ) )
155
+ sourceText = LIBRARY_FILES [ sourcePath ] ;
156
156
else {
157
157
sourceText = readFile ( path . join ( libDirs [ i ] , sourcePath . substring ( LIBRARY_PREFIX . length ) + ".ts" ) ) ;
158
158
if ( sourceText !== null ) {
@@ -169,8 +169,8 @@ function main(argv, options, callback) {
169
169
sourceText = readFile ( path . join ( baseDir , sourcePath , "index.ts" ) ) ;
170
170
if ( sourceText === null ) {
171
171
for ( let i = 0 , k = libDirs . length ; i < k ; ++ i ) {
172
- if ( LIBRARY . hasOwnProperty ( LIBRARY_PREFIX + sourcePath ) )
173
- sourceText = LIBRARY [ LIBRARY_PREFIX + sourcePath ] ;
172
+ if ( LIBRARY_FILES . hasOwnProperty ( LIBRARY_PREFIX + sourcePath ) )
173
+ sourceText = LIBRARY_FILES [ LIBRARY_PREFIX + sourcePath ] ;
174
174
else {
175
175
sourceText = readFile ( path . join ( libDirs [ i ] , sourcePath + ".ts" ) ) ;
176
176
if ( sourceText !== null ) {
@@ -196,10 +196,10 @@ function main(argv, options, callback) {
196
196
// Include (other) library components
197
197
var hasBundledLibrary = false ;
198
198
if ( ! args . noLib )
199
- Object . keys ( LIBRARY ) . forEach ( libPath => {
199
+ Object . keys ( LIBRARY_FILES ) . forEach ( libPath => {
200
200
if ( libPath . lastIndexOf ( "/" ) >= LIBRARY_PREFIX . length ) return ;
201
201
stats . parseCount ++ ;
202
- stats . parseTime += measure ( ( ) => { parser = assemblyscript . parseFile ( LIBRARY [ libPath ] , libPath + ".ts" , parser , false ) ; } ) ;
202
+ stats . parseTime += measure ( ( ) => { parser = assemblyscript . parseFile ( LIBRARY_FILES [ libPath ] , libPath + ".ts" , parser , false ) ; } ) ;
203
203
hasBundledLibrary = true ;
204
204
} ) ;
205
205
for ( let i = 0 , k = libDirs . length ; i < k ; ++ i ) {
0 commit comments