@@ -133,42 +133,55 @@ exports.libpath = function(paths) {
133
133
134
134
exports . loaderCtx = null ;
135
135
136
- op . loadbytecode = /*async*/ function ( ctx , file ) {
137
- // HACK - temporary hack for rakudo-js
138
- if ( file == '/nqp/lib/Perl6/BOOTSTRAP.js' ) {
139
- file = 'Perl6::BOOTSTRAP' ;
140
- }
141
-
142
- let loadFrom ;
143
- if ( ctx && ( ( loadFrom = ctx . lookupDynamic ( '$*LOADBYTECODE_FROM' ) ) !== Null ) ) {
144
- } else {
145
- loadFrom = module ;
146
- }
147
-
148
- const oldLoaderCtx = exports . loaderCtx ;
149
- exports . loaderCtx = ctx ;
150
- const mangled = file . replace ( / : : / g, '-' ) ;
136
+ /* dependencies */
137
+
138
+ if ( process . browser ) {
139
+ op . loadbytecode = /*async*/ function ( ctx , file ) {
140
+ const oldLoaderCtx = exports . loaderCtx ;
141
+ exports . loaderCtx = ctx ;
142
+ file = file . replace ( / \. s e t t i n g $ / , '_setting' ) ;
143
+ file = file . replace ( / : : / g, '-' ) ;
144
+ require ( './' + file + '.nqp-raw-runtime' ) ;
145
+ exports . loaderCtx = oldLoaderCtx ;
146
+ } ;
147
+ } else {
148
+ op . loadbytecode = /*async*/ function ( ctx , file ) {
149
+ // HACK - temporary hack for rakudo-js
150
+ if ( file == '/nqp/lib/Perl6/BOOTSTRAP.js' ) {
151
+ file = 'Perl6::BOOTSTRAP' ;
152
+ }
151
153
152
- const prefixes = libpath . slice ( ) ;
153
- prefixes . push ( './' , './nqp-js-on-js/' ) ;
154
- let found = false ;
155
- for ( const prefix of prefixes ) {
156
- try {
157
- /*await*/ loadFrom . require ( prefix + mangled ) ;
154
+ let loadFrom ;
155
+ if ( ctx && ( ( loadFrom = ctx . lookupDynamic ( '$*LOADBYTECODE_FROM' ) ) !== Null ) ) {
156
+ } else {
157
+ loadFrom = module ;
158
+ }
158
159
159
- found = true ;
160
- break ;
161
- } catch ( e ) {
162
- if ( e . code !== 'MODULE_NOT_FOUND' ) {
163
- throw e ;
160
+ const oldLoaderCtx = exports . loaderCtx ;
161
+ exports . loaderCtx = ctx ;
162
+ const mangled = file . replace ( / : : / g, '-' ) ;
163
+
164
+ const prefixes = libpath . slice ( ) ;
165
+ prefixes . push ( './' , './nqp-js-on-js/' ) ;
166
+ let found = false ;
167
+ for ( const prefix of prefixes ) {
168
+ try {
169
+ /*await*/ loadFrom . require ( prefix + mangled ) ;
170
+
171
+ found = true ;
172
+ break ;
173
+ } catch ( e ) {
174
+ if ( e . code !== 'MODULE_NOT_FOUND' ) {
175
+ throw e ;
176
+ }
164
177
}
165
178
}
166
- }
167
- if ( ! found ) throw `can't find: ${ file } , looking in: ${ prefixes . join ( ', ' ) } from ${ loadFrom . filename } ` ;
168
- exports . loaderCtx = oldLoaderCtx ;
179
+ if ( ! found ) throw `can't find: ${ file } , looking in: ${ prefixes . join ( ', ' ) } from ${ loadFrom . filename } ` ;
180
+ exports . loaderCtx = oldLoaderCtx ;
169
181
170
- return file ;
171
- } ;
182
+ return file ;
183
+ } ;
184
+ }
172
185
173
186
op . loadbytecodefh = function ( ctx , fh , file ) {
174
187
const oldLoaderCtx = exports . loaderCtx ;
0 commit comments