forked from webpack/webpack-cli
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support ES module configuration format (webpack#2381)
- Loading branch information
1 parent
5963ed1
commit 4c4c2eb
Showing
25 changed files
with
191 additions
and
85 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 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.
11 changes: 11 additions & 0 deletions
11
test/config-format/commonjs-default/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,11 @@ | ||
const { run } = require('../../utils/test-utils'); | ||
|
||
describe('webpack cli', () => { | ||
it('should support CommonJS file', () => { | ||
const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.config.cjs'], false); | ||
|
||
expect(exitCode).toBe(0); | ||
expect(stderr).toBeFalsy(); | ||
expect(stdout).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 @@ | ||
console.log('Hoshiumi'); |
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,12 @@ | ||
const path = require('path'); | ||
|
||
const config = { | ||
mode: 'production', | ||
entry: './main.js', | ||
output: { | ||
path: path.resolve(__dirname, 'dist'), | ||
filename: 'foo.bundle.js', | ||
}, | ||
}; | ||
|
||
module.exports.default = config; |
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
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 |
---|---|---|
@@ -1,20 +1,14 @@ | ||
/* eslint-disable node/no-unpublished-require */ | ||
const { run, runInstall } = require('../../utils/test-utils'); | ||
const { run } = require('../../utils/test-utils'); | ||
const { existsSync } = require('fs'); | ||
const { resolve } = require('path'); | ||
|
||
describe('webpack cli', () => { | ||
it.skip( | ||
'should support typescript file', | ||
async () => { | ||
await runInstall(__dirname); | ||
const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.ts']); | ||
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, 'bin/foo.bundle.js'))).toBeTruthy(); | ||
}, | ||
1000 * 60 * 5, | ||
); | ||
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 |
---|---|---|
|
@@ -11,4 +11,4 @@ const config = { | |
}, | ||
}; | ||
|
||
export default config; | ||
export = config; |
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
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
{ | ||
"dependencies": { | ||
"css-loader": "^3.4.2", | ||
"style-loader": "^1.1.3", | ||
"sass-loader": "^8.0.2", | ||
"mini-css-extract-plugin": "^0.9.0", | ||
"node-sass": "^4.13.1" | ||
"css-loader": "^5.0.1", | ||
"style-loader": "^2.0.0", | ||
"sass-loader": "^10.1.1", | ||
"mini-css-extract-plugin": "^1.3.5", | ||
"node-sass": "^5.0.0" | ||
} | ||
} |
Oops, something went wrong.