-
-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support esm format for configurations
- Loading branch information
1 parent
f9ce1d3
commit c4a50db
Showing
25 changed files
with
172 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
function dynamicImportLoader() { | ||
let importESM; | ||
|
||
try { | ||
importESM = new Function('id', 'return import(id);'); | ||
} catch (e) { | ||
importESM = null; | ||
} | ||
|
||
return importESM; | ||
} | ||
|
||
module.exports = dynamicImportLoader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions
14
test/config-format/typescript-commonjs-default/typescript-commonjs-default.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const { run } = require('../../utils/test-utils'); | ||
const { existsSync } = require('fs'); | ||
const { resolve } = require('path'); | ||
|
||
describe('webpack cli', () => { | ||
it('should support typescript file', () => { | ||
const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.ts']); | ||
|
||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toBeTruthy(); | ||
expect(exitCode).toBe(0); | ||
expect(existsSync(resolve(__dirname, 'dist/foo.bundle.js'))).toBeTruthy(); | ||
}); | ||
}); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('Main typescript file'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs" | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
test/config-format/typescript-commonjs/typescript-commonjs.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const { run } = require('../../utils/test-utils'); | ||
const { existsSync } = require('fs'); | ||
const { resolve } = require('path'); | ||
|
||
describe('webpack cli', () => { | ||
it('should support typescript file', () => { | ||
const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.ts']); | ||
|
||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toBeTruthy(); | ||
expect(exitCode).toBe(0); | ||
expect(existsSync(resolve(__dirname, 'dist/foo.bundle.js'))).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* eslint-disable node/no-unsupported-features/es-syntax */ | ||
/** eslint-disable **/ | ||
import * as path from 'path'; | ||
|
||
const config = { | ||
mode: 'production', | ||
entry: './main.ts', | ||
output: { | ||
path: path.resolve(__dirname, 'dist'), | ||
filename: 'foo.bundle.js', | ||
}, | ||
}; | ||
|
||
export = config; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { fileURLToPath } from 'url'; | ||
import path from 'path'; | ||
|
||
export default { | ||
entry: './a.js', | ||
output: { | ||
path: path.resolve(path.dirname(fileURLToPath(import.meta.url)), 'dist'), | ||
filename: 'a.bundle.js', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.