Skip to content

Commit 592fd11

Browse files
authoredJun 2, 2018
fix: fix path lookup & re-add infra docs (#480)
* fix: require validateSchema and optionsValidationError from webpack (#478) * fix: fix lookups
1 parent b1e7ef3 commit 592fd11

File tree

85 files changed

+27575
-109
lines changed

Some content is hidden

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

85 files changed

+27575
-109
lines changed
 

‎bin/cli.js

+3-13
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,6 @@
1616

1717
require("v8-compile-cache");
1818

19-
// try local module, fallback to global
20-
try {
21-
require.resolve("webpack");
22-
process.webpackModule = require("webpack");
23-
} catch (err) {
24-
const globalPathToWebpack = require("global-modules-path").getPath(
25-
"webpack"
26-
);
27-
process.webpackModule = require(globalPathToWebpack);
28-
}
2919
const ErrorHelpers = require("./errorHelpers");
3020

3121
const NON_COMPILATION_ARGS = [
@@ -298,7 +288,7 @@ For more information, see https://webpack.js.org/api/cli/.`);
298288
}
299289

300290
const firstOptions = [].concat(options)[0];
301-
const statsPresetToOptions = process.webpackModule.Stats.presetToOptions;
291+
const statsPresetToOptions = require("webpack").Stats.presetToOptions;
302292

303293
let outputOptions = options.stats;
304294
if (
@@ -443,7 +433,7 @@ For more information, see https://webpack.js.org/api/cli/.`);
443433
outputOptions.buildDelimiter = value;
444434
});
445435

446-
const webpack = process.webpackModule;
436+
const webpack = require("webpack");
447437

448438
let lastHash = null;
449439
let compiler;
@@ -464,7 +454,7 @@ For more information, see https://webpack.js.org/api/cli/.`);
464454
}
465455

466456
if (argv.progress) {
467-
const ProgressPlugin = process.webpackModule.ProgressPlugin;
457+
const ProgressPlugin = require("webpack").ProgressPlugin;
468458
new ProgressPlugin({
469459
profile: argv.profile
470460
}).apply(compiler);

‎bin/convert-argv.js

+13-14
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ fs.existsSync = fs.existsSync || path.existsSync;
44
const interpret = require("interpret");
55
const prepareOptions = require("./prepareOptions");
66
const webpackConfigurationSchema = require("./webpackConfigurationSchema.json");
7-
const validateSchema = process.webpackModule.validateSchema;
8-
const WebpackOptionsValidationError =
9-
process.webpackModule.WebpackOptionsValidationError;
7+
const validateSchema = require("webpack").validateSchema;
8+
const WebpackOptionsValidationError = require("webpack")
9+
.WebpackOptionsValidationError;
1010

1111
module.exports = function(...args) {
1212
const argv = args[1] || args[0];
@@ -398,7 +398,7 @@ module.exports = function(...args) {
398398
defineObject = {};
399399
},
400400
function() {
401-
const DefinePlugin = process.webpackModule.DefinePlugin;
401+
const DefinePlugin = require("webpack").DefinePlugin;
402402
addPlugin(options, new DefinePlugin(defineObject));
403403
}
404404
);
@@ -468,13 +468,13 @@ module.exports = function(...args) {
468468
mapArgToBoolean("cache");
469469

470470
ifBooleanArg("hot", function() {
471-
const HotModuleReplacementPlugin =
472-
process.webpackModule.HotModuleReplacementPlugin;
471+
const HotModuleReplacementPlugin = require("webpack")
472+
.HotModuleReplacementPlugin;
473473
addPlugin(options, new HotModuleReplacementPlugin());
474474
});
475475

476476
ifBooleanArg("debug", function() {
477-
const LoaderOptionsPlugin = process.webpackModule.LoaderOptionsPlugin;
477+
const LoaderOptionsPlugin = require("webpack").LoaderOptionsPlugin;
478478
addPlugin(
479479
options,
480480
new LoaderOptionsPlugin({
@@ -510,8 +510,8 @@ module.exports = function(...args) {
510510
});
511511

512512
ifArg("optimize-max-chunks", function(value) {
513-
const LimitChunkCountPlugin =
514-
process.webpackModule.optimize.LimitChunkCountPlugin;
513+
const LimitChunkCountPlugin = require("webpack").optimize
514+
.LimitChunkCountPlugin;
515515
addPlugin(
516516
options,
517517
new LimitChunkCountPlugin({
@@ -521,8 +521,7 @@ module.exports = function(...args) {
521521
});
522522

523523
ifArg("optimize-min-chunk-size", function(value) {
524-
const MinChunkSizePlugin =
525-
process.webpackModule.optimize.MinChunkSizePlugin;
524+
const MinChunkSizePlugin = require("webpack").optimize.MinChunkSizePlugin;
526525
addPlugin(
527526
options,
528527
new MinChunkSizePlugin({
@@ -532,7 +531,7 @@ module.exports = function(...args) {
532531
});
533532

534533
ifBooleanArg("optimize-minimize", function() {
535-
const LoaderOptionsPlugin = process.webpackModule.LoaderOptionsPlugin;
534+
const LoaderOptionsPlugin = require("webpack").LoaderOptionsPlugin;
536535
addPlugin(
537536
options,
538537
new LoaderOptionsPlugin({
@@ -542,7 +541,7 @@ module.exports = function(...args) {
542541
});
543542

544543
ifArg("prefetch", function(request) {
545-
const PrefetchPlugin = process.webpackModule.PrefetchPlugin;
544+
const PrefetchPlugin = require("webpack").PrefetchPlugin;
546545
addPlugin(options, new PrefetchPlugin(request));
547546
});
548547

@@ -555,7 +554,7 @@ module.exports = function(...args) {
555554
} else {
556555
name = value;
557556
}
558-
const ProvidePlugin = process.webpackModule.ProvidePlugin;
557+
const ProvidePlugin = require("webpack").ProvidePlugin;
559558
addPlugin(options, new ProvidePlugin(name, value));
560559
});
561560

0 commit comments

Comments
 (0)
Please sign in to comment.