11import * as proxyquire from 'proxyquire' ;
22import * as nsWebpackIndex from '../index' ;
33import { join } from 'path' ;
4- import { skipPartiallyEmittedExpressions } from 'typescript' ;
54// With noCallThru enabled, `proxyquire` will not fall back to requiring the real module to populate properties that are not mocked.
65// This allows us to mock packages that are not available in node_modules.
76// In case you want to enable fallback for a specific object, just add `'@noCallThru': false`.
@@ -30,6 +29,7 @@ const nativeScriptDevWebpack = {
3029 PlatformFSPlugin : EmptyClass ,
3130 getAppPath : ( ) => 'app' ,
3231 getEntryModule : ( ) => 'EntryModule' ,
32+ hasRootLevelScopedModules : ( ) => false ,
3333 getResolver : ( ) => null ,
3434 getConvertedExternals : nsWebpackIndex . getConvertedExternals ,
3535 getSourceMapFilename : nsWebpackIndex . getSourceMapFilename ,
@@ -358,6 +358,27 @@ describe('webpack.config.js', () => {
358358 expect ( config . output . sourceMapFilename ) . toEqual ( join ( ".." , newSourceMapFolder , "[file].map" ) ) ;
359359 } ) ;
360360 } ) ;
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+ } ) ;
361382 } ) ;
362383 } ) ;
363384} ) ;
0 commit comments