Skip to content

Commit

Permalink
Adds test
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Jul 14, 2023
1 parent 654dd6b commit cc710d8
Showing 1 changed file with 88 additions and 12 deletions.
100 changes: 88 additions & 12 deletions tests/specs/tsconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@ export default testSuite(({ describe }) => {
'webpack.config.js': `
module.exports = {
mode: 'production',
optimization: {
minimize: false,
},
resolveLoader: {
alias: {
'esbuild-loader': ${JSON.stringify(esbuildLoader)},
},
},
module: {
rules: [{
test: /\\.ts$/,
loader: 'esbuild-loader',
}],
},
entry: './src/index.ts',
output: {
Expand Down Expand Up @@ -82,24 +82,24 @@ export default testSuite(({ describe }) => {
'webpack.config.js': `
module.exports = {
mode: 'production',
optimization: {
minimize: false,
},
resolveLoader: {
alias: {
'esbuild-loader': ${JSON.stringify(esbuildLoader)},
},
},
module: {
rules: [{
test: /\\.ts$/,
loader: 'esbuild-loader',
}],
},
entry: './src/index.ts',
output: {
Expand Down Expand Up @@ -138,17 +138,17 @@ export default testSuite(({ describe }) => {
'webpack.config.js': `
module.exports = {
mode: 'production',
optimization: {
minimize: false,
},
resolveLoader: {
alias: {
'esbuild-loader': ${JSON.stringify(esbuildLoader)},
},
},
module: {
rules: [{
test: /\\.ts$/,
Expand All @@ -158,7 +158,7 @@ export default testSuite(({ describe }) => {
}
}],
},
entry: './src/index.ts',
output: {
Expand Down Expand Up @@ -187,6 +187,82 @@ export default testSuite(({ describe }) => {

await fixture.rm();
});

test('accepts multiple custom tsconfig.json paths', async () => {
const fixture = await createFixture({
src: {
'index.ts': 'export class C { foo = 100; }',
'index2.ts': 'export class C { foo = 100; }',
},
'webpack.config.js': `
module.exports = {
mode: 'production',
optimization: {
minimize: false,
},
resolveLoader: {
alias: {
'esbuild-loader': ${JSON.stringify(esbuildLoader)},
},
},
module: {
rules: [
{
test: /index\\.ts$/,
loader: 'esbuild-loader',
options: {
tsconfig: './tsconfig.custom1.json',
}
},
{
test: /index2\\.ts$/,
loader: 'esbuild-loader',
options: {
tsconfig: './tsconfig.custom2.json',
}
}
],
},
entry: {
index1: './src/index.ts',
index2: './src/index2.ts',
},
output: {
libraryTarget: 'commonjs2',
},
};
`,
'tsconfig.custom1.json': JSON.stringify({
compilerOptions: {
strict: true,
useDefineForClassFields: false,
},
}),
'tsconfig.custom2.json': JSON.stringify({
compilerOptions: {
strict: true,
useDefineForClassFields: true,
},
}),
});

await execa(webpackCli, {
cwd: fixture.path,
});

let code = await fixture.readFile('dist/index1.js', 'utf8');
expect(code).toMatch('this.foo = 100;');

code = await fixture.readFile('dist/index2.js', 'utf8');
expect(code).not.toMatch('this.foo = 100;');

await fixture.rm();
});
});

describe('plugin', ({ test }) => {
Expand Down

0 comments on commit cc710d8

Please sign in to comment.