enhancement(testing): do not bundle node_modules for cypress files

This commit is contained in:
Jason Jean 2019-06-27 12:04:09 -04:00 committed by Victor Savkin
parent 3b699dacef
commit 889d13f3aa
3 changed files with 18 additions and 2 deletions

View File

@ -38,6 +38,7 @@
"@cypress/webpack-preprocessor": "~4.1.0",
"tree-kill": "1.2.1",
"ts-loader": "5.3.1",
"tsconfig-paths-webpack-plugin": "3.2.0"
"tsconfig-paths-webpack-plugin": "3.2.0",
"webpack-node-externals": "1.7.2"
}
}

View File

@ -15,6 +15,7 @@ describe('getWebpackConfig', () => {
expect(config.module.rules).toContainEqual({
test: /\.(j|t)sx?$/,
loader: 'ts-loader',
exclude: [/node_modules/],
options: {
configFile: './tsconfig.json',
// https://github.com/TypeStrong/ts-loader/pull/685
@ -50,4 +51,15 @@ describe('getWebpackConfig', () => {
'.jsx'
]);
});
it('should keep node_modules external', () => {
const config = getWebpackConfig({
env: {
tsConfig: './tsconfig.json'
}
});
const callback = jest.fn();
config.externals[0](null, '@nestjs/core', callback);
expect(callback).toHaveBeenCalledWith(null, 'commonjs @nestjs/core');
});
});

View File

@ -1,5 +1,6 @@
import * as wp from '@cypress/webpack-preprocessor';
import { TsconfigPathsPlugin } from 'tsconfig-paths-webpack-plugin';
import * as nodeExternals from 'webpack-node-externals';
export function preprocessTypescript(config: any) {
if (!config.env.tsConfig) {
@ -30,6 +31,7 @@ export function getWebpackConfig(config: any) {
{
test: /\.(j|t)sx?$/,
loader: 'ts-loader',
exclude: [/node_modules/],
options: {
configFile: config.env.tsConfig,
// https://github.com/TypeStrong/ts-loader/pull/685
@ -37,6 +39,7 @@ export function getWebpackConfig(config: any) {
}
}
]
}
},
externals: [nodeExternals()]
};
}