Skip to content

Commit ab94211

Browse files
committedDec 19, 2017
adds @std/esm and babel-register alias/compat
1 parent 1f24d19 commit ab94211

File tree

68 files changed

+578
-362
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+578
-362
lines changed
 

‎bin/config-yargs.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = function(yargs) {
1919
describe:
2020
"Initializes a new webpack configuration or loads a" +
2121
"\n" +
22-
"plugin if specified",
22+
"addon if specified",
2323
group: INIT_GROUP
2424
},
2525
migrate: {
@@ -53,14 +53,21 @@ module.exports = function(yargs) {
5353
describe: "Generates a new webpack plugin project",
5454
group: INIT_GROUP
5555
},
56-
5756
config: {
5857
type: "string",
5958
describe: "Path to the config file",
6059
group: CONFIG_GROUP,
6160
defaultDescription: "webpack.config.js or webpackfile.js",
6261
requiresArg: true
6362
},
63+
"config-register": {
64+
type: "string",
65+
alias: "r",
Has a conversation. Original line has a conversation.
66+
describe: "Allows to use import/export in the webpack configuration",
67+
group: CONFIG_GROUP,
68+
defaultDescription: "@std/esm or babel-register",
69+
requiresArg: true
70+
},
Has a conversation. Original line has a conversation.
6471
"config-name": {
6572
type: "string",
6673
describe: "Name of the config to use",

‎bin/convert-argv.js

+20-5
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ var fs = require("fs");
33
fs.existsSync = fs.existsSync || path.existsSync;
44
var interpret = require("interpret");
55
var prepareOptions = require("./prepareOptions");
6-
76
module.exports = function(yargs, argv, convertOptions) {
87
var options = [];
9-
108
// Shortcuts
119
if (argv.d) {
1210
argv.debug = true;
@@ -27,7 +25,6 @@ module.exports = function(yargs, argv, convertOptions) {
2725
argv.mode = "production";
2826
}
2927
}
30-
3128
var configFileLoaded = false;
3229
var configFiles = [];
3330
var extensions = Object.keys(interpret.extensions).sort(function(a, b) {
@@ -85,7 +82,6 @@ module.exports = function(yargs, argv, convertOptions) {
8582
}
8683
}
8784
}
88-
8985
if (configFiles.length > 0) {
9086
var registerCompiler = function registerCompiler(moduleDescriptor) {
9187
if (moduleDescriptor) {
@@ -108,7 +104,26 @@ module.exports = function(yargs, argv, convertOptions) {
108104

109105
var requireConfig = function requireConfig(configPath) {
110106
var options = (function WEBPACK_OPTIONS() {
111-
return require(configPath);
Has conversations. Original line has conversations.
107+
if (argv.configRegister === "@std/esm") {
108+
return require(path.resolve(
109+
process.cwd(),
110+
"node_modules",
111+
"@std/esm"
112+
))(module, {
113+
esm: "js"
114+
})(configPath);
115+
} else if (argv.configRegister === "babel-register") {
116+
require(path.resolve(
117+
process.cwd(),
118+
"node_modules",
119+
"babel-register"
120+
))({
121+
presets: ["es2015"]
122+
});
123+
return require(configPath);
124+
} else {
125+
return require(configPath);
126+
}
112127
})();
113128
options = prepareOptions(options, argv);
114129
return options;

0 commit comments

Comments
 (0)
Please sign in to comment.