Skip to content

Commit

Permalink
test: ts esnext (#2584)
Browse files Browse the repository at this point in the history
  • Loading branch information
anshumanv committed Apr 5, 2021
1 parent 2bf24dd commit 4617050
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/build/config-format/typescript-esnext/main.ts
@@ -0,0 +1 @@
console.log('Rimuru Tempest');
3 changes: 3 additions & 0 deletions test/build/config-format/typescript-esnext/package.json
@@ -0,0 +1,3 @@
{
"type": "module"
}
6 changes: 6 additions & 0 deletions test/build/config-format/typescript-esnext/tsconfig.json
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"module": "esnext",
"allowSyntheticDefaultImports": true
}
}
30 changes: 30 additions & 0 deletions test/build/config-format/typescript-esnext/typescript.test.js
@@ -0,0 +1,30 @@
// eslint-disable-next-line node/no-unpublished-require
const { run, isWebpack5 } = require('../../../utils/test-utils');
const { existsSync } = require('fs');
const { resolve } = require('path');

describe('webpack cli', () => {
it('should support typescript esnext file', async () => {
const isMacOS = process.platform === 'darwin';
const majorNodeVersion = process.version.slice(1, 3);
if (majorNodeVersion < 14) {
expect(true).toBe(true);

return;
}

if (isMacOS && !isWebpack5) {
expect(true).toBe(true);

return;
}

const { exitCode, stderr, stdout } = await run(__dirname, ['-c', './webpack.config.ts'], {
nodeOptions: ['--loader=ts-node/esm'],
});
expect(stderr).not.toBeFalsy();
expect(stdout).toBeTruthy();
expect(exitCode).toBe(0);
expect(existsSync(resolve(__dirname, 'dist/foo.bundle.js'))).toBeTruthy();
});
});
13 changes: 13 additions & 0 deletions test/build/config-format/typescript-esnext/webpack.config.ts
@@ -0,0 +1,13 @@
/* eslint-disable node/no-unsupported-features/es-syntax */
import * as path from 'path';

const config = {
mode: 'production',
entry: './main.ts',
output: {
path: path.resolve('dist'),
filename: 'foo.bundle.js',
},
};

export default config;

0 comments on commit 4617050

Please sign in to comment.