@@ -5,6 +5,10 @@ import * as child from 'child_process'
55import * as webpack from 'webpack'
66import { exec as shellExec } from 'shelljs'
77
8+ process . on ( 'unhandledRejection' , e => {
9+ throw e
10+ } )
11+
812import { LoaderConfig } from '../interfaces'
913
1014require ( 'source-map-support' ) . install ( )
@@ -32,8 +36,9 @@ export interface ConfigOptions {
3236const TEST_DIR = path . join ( process . cwd ( ) , '.test' )
3337const SRC_DIR = './src'
3438const OUT_DIR = './out'
39+
3540const WEBPACK = path . join (
36- path . dirname ( path . dirname ( require . resolve ( 'webpack' ) ) ) ,
41+ path . dirname ( path . dirname ( require . resolve ( 'webpack-cli ' ) ) ) ,
3742 'bin' ,
3843 'webpack.js'
3944)
@@ -50,13 +55,13 @@ export function entry(file: string) {
5055
5156export function query ( q : any ) {
5257 return config => {
53- _ . merge ( config . module . loaders . find ( loader => loader . loader === LOADER ) . query , q )
58+ _ . merge ( config . module . rules . find ( loader => loader . loader === LOADER ) . query , q )
5459 }
5560}
5661
5762export function include ( ...folders : string [ ] ) {
5863 return config => {
59- config . module . loaders . find ( loader => loader . loader === LOADER ) . include . push (
64+ config . module . rules . find ( loader => loader . loader === LOADER ) . include . push (
6065 ...folders . map ( f => {
6166 return path . join ( process . cwd ( ) , f )
6267 } )
@@ -65,7 +70,8 @@ export function include(...folders: string[]) {
6570}
6671
6772export function webpackConfig ( ...enchance : any [ ] ) : webpack . Configuration {
68- const config = {
73+ const config : webpack . Configuration = {
74+ mode : 'development' ,
6975 entry : { index : path . join ( process . cwd ( ) , SRC_DIR , 'index.ts' ) } ,
7076 output : {
7177 path : path . join ( process . cwd ( ) , OUT_DIR ) ,
@@ -75,7 +81,7 @@ export function webpackConfig(...enchance: any[]): webpack.Configuration {
7581 extensions : [ '.ts' , '.tsx' , '.js' , '.jsx' ]
7682 } ,
7783 module : {
78- loaders : [
84+ rules : [
7985 {
8086 test : / \. ( t s x ? | j s x ? ) / ,
8187 loader : LOADER ,
@@ -285,7 +291,7 @@ export function checkOutput(fileName: string, fragment: string) {
285291 process . exit ( )
286292 }
287293
288- expect ( source . replace ( / \s / g, '' ) ) . include ( fragment . replace ( / \s / g, '' ) )
294+ expect ( source . replace ( / ( [ \s \n ] | \\ n ) / g, '' ) ) . include ( fragment . replace ( / ( [ \s \n ] | \\ n ) / g, '' ) )
289295}
290296
291297export function readOutput ( fileName : string ) {
0 commit comments