ESM: Config scripts now run synchronously before webpack builds start
This commit is contained in:
parent
23f69bd21d
commit
4e38b09e18
15
package-lock.json
generated
15
package-lock.json
generated
@ -12652,12 +12652,6 @@
|
||||
"integrity": "sha1-Iyxi7GCSsQBjWj0p2DwXRxKN+b0=",
|
||||
"dev": true
|
||||
},
|
||||
"webpack-shell-plugin": {
|
||||
"version": "0.5.0",
|
||||
"resolved": "https://registry.npmjs.org/webpack-shell-plugin/-/webpack-shell-plugin-0.5.0.tgz",
|
||||
"integrity": "sha1-Kbih2A3erg3bEOcpZn9yhlPCx0I=",
|
||||
"dev": true
|
||||
},
|
||||
"webpack-sources": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.0.1.tgz",
|
||||
@ -12668,6 +12662,15 @@
|
||||
"source-map": "0.5.7"
|
||||
}
|
||||
},
|
||||
"webpack-synchronizable-shell-plugin": {
|
||||
"version": "0.0.7",
|
||||
"resolved": "https://registry.npmjs.org/webpack-synchronizable-shell-plugin/-/webpack-synchronizable-shell-plugin-0.0.7.tgz",
|
||||
"integrity": "sha512-b1ZPHwkHR5+MDRLp9CbLxDaaTTcf4/tmxU+Tc6Z3lpv6krnIPv0doXfgBHkDthHUkwsURyO9fgRnJ/VxyFBEwQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"babel-polyfill": "6.26.0"
|
||||
}
|
||||
},
|
||||
"websocket-driver": {
|
||||
"version": "0.7.0",
|
||||
"resolved": "https://registry.npmjs.org/websocket-driver/-/websocket-driver-0.7.0.tgz",
|
||||
|
@ -63,7 +63,7 @@
|
||||
"webpack": "^4.0.1",
|
||||
"webpack-dev-server": "^3.1.0",
|
||||
"webpack-node-externals": "^1.6.0",
|
||||
"webpack-shell-plugin": "^0.5.0",
|
||||
"webpack-synchronizable-shell-plugin": "0.0.7",
|
||||
"worker-loader": "^1.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
|
@ -52,21 +52,20 @@ for (const opObj in Ops) {
|
||||
/**
|
||||
* Write OperationConfig.
|
||||
*/
|
||||
fs.writeFile(
|
||||
fs.writeFileSync(
|
||||
path.join(dir, "OperationConfig.json"),
|
||||
JSON.stringify(operationConfig, null, 4),
|
||||
err => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
JSON.stringify(operationConfig, null, 4)
|
||||
);
|
||||
console.log("Written OperationConfig.json");
|
||||
|
||||
|
||||
/**
|
||||
* Write modules.
|
||||
*/
|
||||
if (!fs.existsSync(path.join(dir, "modules/"))) {
|
||||
fs.mkdirSync(path.join(dir, "modules/"));
|
||||
}
|
||||
|
||||
for (const module in modules) {
|
||||
let code = `/**
|
||||
* THIS FILE IS AUTOMATICALLY GENERATED BY src/core/config/scripts/generateConfig.mjs
|
||||
@ -96,16 +95,11 @@ OpModules.${module} = {
|
||||
|
||||
export default OpModules;
|
||||
`;
|
||||
fs.writeFile(
|
||||
fs.writeFileSync(
|
||||
path.join(dir, `modules/${module}.mjs`),
|
||||
code,
|
||||
err => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
code
|
||||
);
|
||||
console.log(`Written ${module} module`);
|
||||
}
|
||||
|
||||
|
||||
@ -143,16 +137,11 @@ opModulesCode += `);
|
||||
export default OpModules;
|
||||
`;
|
||||
|
||||
fs.writeFile(
|
||||
fs.writeFileSync(
|
||||
path.join(dir, "modules/OpModules.mjs"),
|
||||
opModulesCode,
|
||||
err => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
opModulesCode
|
||||
);
|
||||
console.log("Written OpModules.mjs");
|
||||
|
||||
|
||||
/*"Fork": {
|
||||
|
@ -57,3 +57,4 @@ fs.writeFileSync(
|
||||
path.join(dir, "../operations/index.mjs"),
|
||||
code
|
||||
);
|
||||
console.log("Written operation index.");
|
||||
|
@ -1,6 +1,6 @@
|
||||
const webpack = require("webpack");
|
||||
const ExtractTextPlugin = require("extract-text-webpack-plugin");
|
||||
const WebpackShellPlugin = require("webpack-shell-plugin");
|
||||
const WebpackSyncShellPlugin = require("webpack-synchronizable-shell-plugin");
|
||||
|
||||
/**
|
||||
* Webpack configuration details for use with Grunt.
|
||||
@ -44,11 +44,16 @@ module.exports = {
|
||||
entryOnly: true
|
||||
}),
|
||||
new ExtractTextPlugin("styles.css"),
|
||||
new WebpackShellPlugin({
|
||||
onBuildStart: [
|
||||
"node --experimental-modules src/core/config/scripts/generateOpsIndex.mjs",
|
||||
"node --experimental-modules src/core/config/scripts/generateConfig.mjs",
|
||||
],
|
||||
new WebpackSyncShellPlugin({
|
||||
onBuildStart: {
|
||||
scripts: [
|
||||
"node --experimental-modules src/core/config/scripts/generateOpsIndex.mjs",
|
||||
"node --experimental-modules src/core/config/scripts/generateConfig.mjs",
|
||||
"echo ---\nConfig scripts finished.\n---\n"
|
||||
],
|
||||
blocking: true,
|
||||
parallel: false
|
||||
}
|
||||
})
|
||||
],
|
||||
resolve: {
|
||||
|
Loading…
Reference in New Issue
Block a user