Skip to content

Commit

Permalink
cli(symlinks): Fix paths (#453)
Browse files Browse the repository at this point in the history
* cli(symlinks): fix symlinks

* chore(linting): resolve linting errors

* chore(rebase): remove old file
  • Loading branch information
evenstensberg authored May 21, 2018
1 parent 0310fd3 commit 217670f
Show file tree
Hide file tree
Showing 12 changed files with 8,775 additions and 4,331 deletions.
17 changes: 14 additions & 3 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@
}

require("v8-compile-cache");

// try local module, fallback to global
try {
require.resolve("webpack");
process.webpackModule = require("webpack");
} catch (err) {
const globalPathToWebpack = require("global-modules-path").getPath(
"webpack"
);
process.webpackModule = require(globalPathToWebpack);
}
const ErrorHelpers = require("./errorHelpers");

const NON_COMPILATION_ARGS = [
Expand Down Expand Up @@ -287,7 +298,7 @@ For more information, see https://webpack.js.org/api/cli/.`);
}

const firstOptions = [].concat(options)[0];
const statsPresetToOptions = require("webpack").Stats.presetToOptions;
const statsPresetToOptions = process.webpackModule.Stats.presetToOptions;

let outputOptions = options.stats;
if (
Expand Down Expand Up @@ -432,7 +443,7 @@ For more information, see https://webpack.js.org/api/cli/.`);
outputOptions.buildDelimiter = value;
});

const webpack = require("webpack");
const webpack = process.webpackModule;

let lastHash = null;
let compiler;
Expand All @@ -453,7 +464,7 @@ For more information, see https://webpack.js.org/api/cli/.`);
}

if (argv.progress) {
const ProgressPlugin = require("webpack").ProgressPlugin;
const ProgressPlugin = process.webpackModule.ProgressPlugin;
new ProgressPlugin({
profile: argv.profile
}).apply(compiler);
Expand Down
2 changes: 1 addition & 1 deletion bin/config-yargs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const optionsSchema = require("webpack/schemas/WebpackOptions.json");
const optionsSchema = require("./optionsSchema.json");
const CONFIG_GROUP = "Config options:";
const BASIC_GROUP = "Basic options:";
const MODULE_GROUP = "Module options:";
Expand Down
27 changes: 14 additions & 13 deletions bin/convert-argv.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ fs.existsSync = fs.existsSync || path.existsSync;
const interpret = require("interpret");
const prepareOptions = require("./prepareOptions");
const webpackConfigurationSchema = require("./webpackConfigurationSchema.json");
const validateSchema = require("webpack").validateSchema;
const WebpackOptionsValidationError = require("webpack")
.WebpackOptionsValidationError;
const validateSchema = process.webpackModule.validateSchema;
const WebpackOptionsValidationError =
process.webpackModule.WebpackOptionsValidationError;

module.exports = function(...args) {
const argv = args[1] || args[0];
Expand Down Expand Up @@ -398,7 +398,7 @@ module.exports = function(...args) {
defineObject = {};
},
function() {
const DefinePlugin = require("webpack").DefinePlugin;
const DefinePlugin = process.webpackModule.DefinePlugin;
addPlugin(options, new DefinePlugin(defineObject));
}
);
Expand Down Expand Up @@ -468,13 +468,13 @@ module.exports = function(...args) {
mapArgToBoolean("cache");

ifBooleanArg("hot", function() {
const HotModuleReplacementPlugin = require("webpack")
.HotModuleReplacementPlugin;
const HotModuleReplacementPlugin =
process.webpackModule.HotModuleReplacementPlugin;
addPlugin(options, new HotModuleReplacementPlugin());
});

ifBooleanArg("debug", function() {
const LoaderOptionsPlugin = require("webpack").LoaderOptionsPlugin;
const LoaderOptionsPlugin = process.webpackModule.LoaderOptionsPlugin;
addPlugin(
options,
new LoaderOptionsPlugin({
Expand Down Expand Up @@ -510,8 +510,8 @@ module.exports = function(...args) {
});

ifArg("optimize-max-chunks", function(value) {
const LimitChunkCountPlugin = require("webpack").optimize
.LimitChunkCountPlugin;
const LimitChunkCountPlugin =
process.webpackModule.optimize.LimitChunkCountPlugin;
addPlugin(
options,
new LimitChunkCountPlugin({
Expand All @@ -521,7 +521,8 @@ module.exports = function(...args) {
});

ifArg("optimize-min-chunk-size", function(value) {
const MinChunkSizePlugin = require("webpack").optimize.MinChunkSizePlugin;
const MinChunkSizePlugin =
process.webpackModule.optimize.MinChunkSizePlugin;
addPlugin(
options,
new MinChunkSizePlugin({
Expand All @@ -531,7 +532,7 @@ module.exports = function(...args) {
});

ifBooleanArg("optimize-minimize", function() {
const LoaderOptionsPlugin = require("webpack").LoaderOptionsPlugin;
const LoaderOptionsPlugin = process.webpackModule.LoaderOptionsPlugin;
addPlugin(
options,
new LoaderOptionsPlugin({
Expand All @@ -541,7 +542,7 @@ module.exports = function(...args) {
});

ifArg("prefetch", function(request) {
const PrefetchPlugin = require("webpack").PrefetchPlugin;
const PrefetchPlugin = process.webpackModule.PrefetchPlugin;
addPlugin(options, new PrefetchPlugin(request));
});

Expand All @@ -554,7 +555,7 @@ module.exports = function(...args) {
} else {
name = value;
}
const ProvidePlugin = require("webpack").ProvidePlugin;
const ProvidePlugin = process.webpackModule.ProvidePlugin;
addPlugin(options, new ProvidePlugin(name, value));
});

Expand Down
Loading

0 comments on commit 217670f

Please sign in to comment.