Skip to content

Commit

Permalink
[fix] defer webpack partial config loading
Browse files Browse the repository at this point in the history
  • Loading branch information
jchip committed Apr 28, 2021
1 parent c6cb1ad commit 447a4f1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions packages/xarc-webpack/src/partials/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import * as Fs from "fs";
const assert = require("assert");
const Partial = require("webpack-config-composer/lib/partial");


//
// This specifies a general order of partials to be applied.
// Any new partial need to be added here. Name is the filename
Expand Down Expand Up @@ -57,7 +56,7 @@ const files = Fs.readdirSync(__dirname)
const partials = files.reduce((a, p) => {
const k = `_${p}`;
assert(orders.indexOf(k) >= 0, `No default order specified for partial ${p}`);
a[k] = new Partial(k, { config: require(`./${p}`) });
a[k] = new Partial(k, { config: () => require(`./${p}`) });
a[k].options.order = (orders.indexOf(k) + 1) * 100;
return a;
}, {});
Expand Down
3 changes: 2 additions & 1 deletion packages/xarc-webpack/src/util/generate-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import * as _ from "lodash";
import * as Path from "path";

const xsh = require("xsh");
const partials = require("../partials");
const WebpackConfigComposer = require("webpack-config-composer");
const optionalRequire = require("optional-require")(require);
import { logger } from "@xarc/dev-base";
Expand Down Expand Up @@ -66,6 +65,8 @@ function searchUserCustomConfig(options) {
// returns a new options copy
//
export function initWebpackConfigComposer(options) {
const partials = require("../partials");

options = Object.assign({ profileNames: [] }, options);

if (!options.composer) {
Expand Down

0 comments on commit 447a4f1

Please sign in to comment.