@@ -22,15 +22,15 @@ try {
2222
2323// Common constants
2424
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" ) ;
2728const SOURCEMAP_ROOT = "assemblyscript:///" ;
2829const 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 : { } ;
3434
3535function main ( argv , options , callback ) {
3636 if ( typeof options === "function" ) {
@@ -151,8 +151,8 @@ function main(argv, options, callback) {
151151 // Load library file if explicitly requested
152152 if ( sourcePath . startsWith ( LIBRARY_PREFIX ) ) {
153153 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 ] ;
156156 else {
157157 sourceText = readFile ( path . join ( libDirs [ i ] , sourcePath . substring ( LIBRARY_PREFIX . length ) + ".ts" ) ) ;
158158 if ( sourceText !== null ) {
@@ -169,8 +169,8 @@ function main(argv, options, callback) {
169169 sourceText = readFile ( path . join ( baseDir , sourcePath , "index.ts" ) ) ;
170170 if ( sourceText === null ) {
171171 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 ] ;
174174 else {
175175 sourceText = readFile ( path . join ( libDirs [ i ] , sourcePath + ".ts" ) ) ;
176176 if ( sourceText !== null ) {
@@ -196,10 +196,10 @@ function main(argv, options, callback) {
196196 // Include (other) library components
197197 var hasBundledLibrary = false ;
198198 if ( ! args . noLib )
199- Object . keys ( LIBRARY ) . forEach ( libPath => {
199+ Object . keys ( LIBRARY_FILES ) . forEach ( libPath => {
200200 if ( libPath . lastIndexOf ( "/" ) >= LIBRARY_PREFIX . length ) return ;
201201 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 ) ; } ) ;
203203 hasBundledLibrary = true ;
204204 } ) ;
205205 for ( let i = 0 , k = libDirs . length ; i < k ; ++ i ) {
0 commit comments