1
1
import * as proxyquire from 'proxyquire' ;
2
2
import * as nsWebpackIndex from '../index' ;
3
3
import { join } from 'path' ;
4
- import { skipPartiallyEmittedExpressions } from 'typescript' ;
5
4
// With noCallThru enabled, `proxyquire` will not fall back to requiring the real module to populate properties that are not mocked.
6
5
// This allows us to mock packages that are not available in node_modules.
7
6
// In case you want to enable fallback for a specific object, just add `'@noCallThru': false`.
@@ -359,6 +358,27 @@ describe('webpack.config.js', () => {
359
358
expect ( config . output . sourceMapFilename ) . toEqual ( join ( ".." , newSourceMapFolder , "[file].map" ) ) ;
360
359
} ) ;
361
360
} ) ;
361
+
362
+ describe ( `alias for webpack.${ type } .js (${ platform } )` , ( ) => {
363
+ it ( 'should add alias when @nativescript/core is at the root of node_modules' , ( ) => {
364
+ nativeScriptDevWebpack . hasRootLevelScopedModules = ( ) => true ;
365
+ const input = getInput ( { platform } ) ;
366
+ const config = webpackConfig ( input ) ;
367
+ expect ( config . resolve . alias [ 'tns-core-modules' ] ) . toBe ( '@nativescript/core' ) ;
368
+ if ( type === 'angular' ) {
369
+ expect ( config . resolve . alias [ 'nativescript-angular' ] ) . toBe ( '@nativescript/angular' ) ;
370
+ }
371
+ } ) ;
372
+ it ( 'shouldn\'t add alias when @nativescript/core is not at the root of node_modules' , ( ) => {
373
+ nativeScriptDevWebpack . hasRootLevelScopedModules = ( ) => false ;
374
+ const input = getInput ( { platform } ) ;
375
+ const config = webpackConfig ( input ) ;
376
+ expect ( config . resolve . alias [ 'tns-core-modules' ] ) . toBeUndefined ( ) ;
377
+ if ( type === 'angular' ) {
378
+ expect ( config . resolve . alias [ 'nativescript-angular' ] ) . toBeUndefined ( ) ;
379
+ }
380
+ } ) ;
381
+ } ) ;
362
382
} ) ;
363
383
} ) ;
364
384
} ) ;
0 commit comments