Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli(symlinks): Fix paths #453

Merged
merged 4 commits into from
May 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sokra you might have to do the same thing at webpack/binonce we publish the next branch to master. Path lookups are failing, and adjusting them according to their global/local paths aren't helping...

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