@oroinc/oro-webpack-config-builder 5.1.0-alpha29 → 5.1.0-alpha32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,70 @@
1
+ module.exports = function (e) {
2
+ var n = {};
3
+
4
+ function t(i) {
5
+ if (n[i]) return n[i].exports;
6
+ var r = n[i] = {i: i, l: !1, exports: {}};
7
+ return e[i].call(r.exports, r, r.exports, t), r.l = !0, r.exports
8
+ }
9
+
10
+ return t.m = e, t.c = n, t.d = function (e, n, i) {
11
+ t.o(e, n) || Object.defineProperty(e, n, {configurable: !1, enumerable: !0, get: i})
12
+ }, t.r = function (e) {
13
+ Object.defineProperty(e, "__esModule", {value: !0})
14
+ }, t.n = function (e) {
15
+ var n = e && e.__esModule ? function () {
16
+ return e.default
17
+ } : function () {
18
+ return e
19
+ };
20
+ return t.d(n, "a", n), n
21
+ }, t.o = function (e, n) {
22
+ return Object.prototype.hasOwnProperty.call(e, n)
23
+ }, t.p = "", t.w = {}, t(t.s = 3)
24
+ }([function (e, n) {
25
+ e.exports = require("babel-core")
26
+ }, function (e, n, t) {
27
+ "use strict";
28
+ Object.defineProperty(n, "__esModule", {value: !0});
29
+ var i = t(0);
30
+ n.default = (0, i.template)("\n module.exports = function __injector(__injections) {\n __injections = __injections || {};\n\n (function __validateInjection() {\n var validDependencies = DEPENDENCIES;\n var injectedDependencies = Object.keys(__injections);\n var invalidInjectedDependencies = injectedDependencies.filter(function (dependency) {\n return validDependencies.indexOf(dependency) === -1;\n });\n\n if (invalidInjectedDependencies.length > 0) {\n var validDependenciesString = ' - ' + validDependencies.join('\\n - ');\n var injectedDependenciesString = ' - ' + injectedDependencies.join('\\n - ');\n var invalidDependenciesString = ' - ' + invalidInjectedDependencies.join('\\n - ');\n\n throw new Error('Injection Error in ' + SOURCE_PATH + '\\n\\n' +\n 'The following injections are invalid:\\n' + invalidDependenciesString + '\\n\\n' +\n 'The following injections were passed in:\\n' + injectedDependenciesString + '\\n\\n' +\n 'Valid injection targets for this module are:\\n' + validDependenciesString + '\\n'\n );\n }\n })();\n\n __injector.sourcePath = SOURCE_PATH;\n __injector.validDependencies = DEPENDENCIES;\n\n var module = { exports: {} };\n var exports = module.exports;\n\n (function () {\n SOURCE\n })();\n\n return module.exports;\n }\n"), e.exports = n.default
31
+ }, function (e, n, t) {
32
+ "use strict";
33
+ Object.defineProperty(n, "__esModule", {value: !0}), n.default = function (e, n, t) {
34
+ var i = (0, r.transform)(n, {babelrc: !1, code: !1, compact: !1, filename: e.resourcePath}).ast, o = [];
35
+ (0, r.traverse)(i, {
36
+ CallExpression: function (e) {
37
+ r.types.isIdentifier(e.node.callee, {name: "require"}) && (o.push(function (e) {
38
+ var n = e.node.arguments[0].value;
39
+ return e.replaceWith(r.types.expressionStatement(r.types.conditionalExpression(r.types.callExpression(r.types.memberExpression(r.types.identifier("__injections"), r.types.identifier("hasOwnProperty"), !1), [r.types.stringLiteral(n)]), r.types.memberExpression(r.types.identifier("__injections"), r.types.stringLiteral(n), !0), e.node))), n
40
+ }(e)), e.skip())
41
+ }
42
+ }), 0 === o.length && e.emitWarning("The module you are trying to inject into doesn't have any dependencies. Are you sure you want to do this?");
43
+ var a = r.types.file(r.types.program([(0, s.default)({
44
+ SOURCE: i,
45
+ SOURCE_PATH: r.types.stringLiteral(e.resourcePath),
46
+ DEPENDENCIES: r.types.arrayExpression(o.map(function (e) {
47
+ return r.types.stringLiteral(e)
48
+ }))
49
+ })]));
50
+ return (0, r.transformFromAst)(a, n, {
51
+ sourceMaps: e.sourceMap,
52
+ sourceFileName: e.resourcePath,
53
+ inputSourceMap: t,
54
+ babelrc: !1,
55
+ compact: !1,
56
+ filename: e.resourcePath
57
+ })
58
+ };
59
+ var i, r = t(0), o = t(1), s = (i = o) && i.__esModule ? i : {default: i};
60
+ e.exports = n.default
61
+ }, function (e, n, t) {
62
+ "use strict";
63
+ Object.defineProperty(n, "__esModule", {value: !0}), n.default = function (e, n) {
64
+ this.cacheable && this.cacheable();
65
+ var t = (0, o.default)(this, e, n), i = t.code, r = t.map;
66
+ this.callback(null, i, r)
67
+ };
68
+ var i, r = t(2), o = (i = r) && i.__esModule ? i : {default: i};
69
+ e.exports = n.default
70
+ }]);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["webpack:///webpack/bootstrap 393a9525777b8b817cc3","webpack:///external \"babel-core\"","webpack:///src/index.js","webpack:///src/injectify.js","webpack:///src/wrapper_template.js"],"sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 393a9525777b8b817cc3","module.exports = require(\"babel-core\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"babel-core\"\n// module id = 0\n// module chunks = 0","// @flow\n\nimport injectify from './injectify.js';\n\nexport default function injectifyLoader(source, inputSourceMap) {\n if (this.cacheable) {\n this.cacheable();\n }\n\n const { code, map } = injectify(this, source, inputSourceMap);\n this.callback(null, code, map);\n}\n\n\n\n// WEBPACK FOOTER //\n// src/index.js","// @flow\n\nimport { transform, traverse, types as t, transformFromAst } from 'babel-core';\nimport wrapperTemplate from './wrapper_template.js';\n\nfunction processRequireCall(path) {\n const dependencyString = path.node.arguments[0].value;\n path.replaceWith(\n t.expressionStatement(\n t.conditionalExpression(\n t.callExpression(\n t.memberExpression(\n t.identifier('__injections'),\n t.identifier('hasOwnProperty'),\n false,\n ),\n [\n t.stringLiteral(dependencyString),\n ],\n ),\n t.memberExpression(\n t.identifier('__injections'),\n t.stringLiteral(dependencyString),\n true,\n ),\n path.node,\n ),\n ),\n );\n\n return dependencyString;\n}\n\nexport default function injectify(context, source, inputSourceMap) {\n const { ast } = transform(source, {\n babelrc: false,\n code: false,\n compact: false,\n filename: context.resourcePath,\n });\n\n const dependencies = [];\n traverse(ast, {\n CallExpression(path) {\n if (t.isIdentifier(path.node.callee, { name: 'require' })) {\n dependencies.push(processRequireCall(path));\n path.skip();\n }\n },\n });\n\n if (dependencies.length === 0) {\n context.emitWarning('The module you are trying to inject into doesn\\'t have any dependencies. ' +\n 'Are you sure you want to do this?');\n }\n\n const dependenciesArrayAst = t.arrayExpression(\n dependencies.map(dependency => t.stringLiteral(dependency)),\n );\n const wrapperModuleAst = t.file(t.program([\n wrapperTemplate({ SOURCE: ast, DEPENDENCIES: dependenciesArrayAst }),\n ]));\n\n return transformFromAst(wrapperModuleAst, source, {\n sourceMaps: context.sourceMap,\n sourceFileName: context.resourcePath,\n inputSourceMap,\n babelrc: false,\n compact: false,\n filename: context.resourcePath,\n });\n}\n\n\n\n// WEBPACK FOOTER //\n// src/injectify.js","// @flow\n\nimport { template } from 'babel-core';\n\nexport default template(`\n module.exports = function __injector(__injections) {\n __injections = __injections || {};\n\n (function __validateInjection() {\n var validDependencies = DEPENDENCIES;\n var injectedDependencies = Object.keys(__injections);\n var invalidInjectedDependencies = injectedDependencies.filter(function (dependency) {\n return validDependencies.indexOf(dependency) === -1;\n });\n\n if (invalidInjectedDependencies.length > 0) {\n var validDependenciesString = '- ' + validDependencies.join('\\\\n- ');\n var injectedDependenciesString = '- ' + injectedDependencies.join('\\\\n- ');\n var invalidDependenciesString = '- ' + invalidInjectedDependencies.join('\\\\n- ');\n\n throw new Error('Some of the injections you passed in are invalid.\\\\n' +\n 'Valid injection targets for this module are:\\\\n' + validDependenciesString + '\\\\n' +\n 'The following injections were passed in:\\\\n' + injectedDependenciesString + '\\\\n' +\n 'The following injections are invalid:\\\\n' + invalidDependenciesString + '\\\\n'\n );\n }\n })();\n\n var module = { exports: {} };\n var exports = module.exports;\n\n (function () {\n SOURCE\n })();\n\n return module.exports;\n }\n`);\n\n\n\n// WEBPACK FOOTER //\n// src/wrapper_template.js"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC7DA;;;;;;;;;;;;;;;;;;;ACIA;AACA;AAHA;AACA;;;;;AACA;AACA;AACA;AACA;AACA;AAJA;AAAA;AAAA;AACA;AAKA;AACA;AACA;;;;;;;;;;;;;ACqBA;AACA;AAhCA;AACA;AAAA;AACA;;;;;AAJA;AACA;AAIA;AACA;AACA;AACA;AAsBA;AACA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AAJA;AADA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AANA;AACA;AAQA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAEA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AANA;AAQA;;;;;;;;;;;;;;ACrEA;AACA;AACA;AACA;;;;A","sourceRoot":""}
package/messages.js ADDED
@@ -0,0 +1,29 @@
1
+ const doc = "Please, find more information in the documentation ";
2
+ const CSSError = "Failed assembly styles.\n";
3
+ const CSSDoc = "https://doc.oroinc.com/backend/bundles/platform/AssetBundle/#load-scss-or-css-files-from-the-bundle";
4
+ const JSError = `Failed assembly JS.\n`;
5
+ const JSDoc = "https://doc.oroinc.com/backend/bundles/platform/AssetBundle/#create-jsmodules-yml-configuration";
6
+ const JSExtraBuildDoc = "https://doc.oroinc.com/master/frontend/storefront/how-to/how-to-create-extra-js-build-for-landing-page";
7
+
8
+ module.exports = {
9
+ assetsMissedOutput(group, theme) {
10
+ const error = `The "output" for "${group}" entry point in "${theme}" theme is not defined.\n`;
11
+
12
+ return `${CSSError}${error}${doc}${CSSDoc}`;
13
+ },
14
+ assetsMissedInput(group, theme) {
15
+ const error = `The "output" for "${group}" entry point in "${theme}" theme is not defined.\n`;
16
+
17
+ return `${CSSError}${error}${doc}${CSSDoc}`
18
+ },
19
+ jsModulesError(theme) {
20
+ const error = `Failed assembly JS for the "${theme}" theme.\n`;
21
+
22
+ return `${error}${doc}${JSDoc}`
23
+ },
24
+ jsExtraModulesError(parts) {
25
+ const error = `Sections ["${parts.join('", "')}"] are not allowed in extra js build definition\n`;
26
+
27
+ return `${JSError}${error}${doc}${JSExtraBuildDoc}`;
28
+ }
29
+ };
@@ -23,6 +23,7 @@ const resolve = require('enhanced-resolve');
23
23
  const {merge: webpackMerge} = require('webpack-merge');
24
24
  const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
25
25
  const RtlCssWebpackPlugin = require('rtlcss-webpack-plugin');
26
+ const {red: colorRed} = require('colorette');
26
27
  require('resolve-url-loader');
27
28
 
28
29
  class ConfigBuilder {
@@ -127,12 +128,26 @@ class ConfigBuilder {
127
128
  return (env = {}, args = {}) => {
128
129
  this._initialize(args, env);
129
130
 
130
- const commonConfig = this._getCommonWebpackConfig(args, env);
131
+ let commonConfig = {};
132
+ try {
133
+ commonConfig = this._getCommonWebpackConfig(args, env);
134
+ } catch (e) {
135
+ console.error(colorRed(`Error: ${e.message}`));
136
+ process.exit(1);
137
+ }
138
+
131
139
  const webpackConfigs = [];
132
140
  const requestedBuildNames = env.theme ? env.theme.split(',') : [];
133
141
  const buildNames = this._getBuildNames(requestedBuildNames);
134
142
  buildNames.forEach(buildName => {
135
- const buildConfig = this._getThemeWebpackConfig(buildName, args, env);
143
+ let buildConfig;
144
+ try {
145
+ buildConfig = this._getThemeWebpackConfig(buildName, args, env);
146
+ } catch (e) {
147
+ console.error(colorRed(`Error: ${e.message}`));
148
+ return;
149
+ }
150
+
136
151
  if (buildConfig) {
137
152
  webpackConfigs.push(webpackMerge(buildConfig, commonConfig));
138
153
  }
package/package.json CHANGED
@@ -1,49 +1,49 @@
1
1
  {
2
2
  "name": "@oroinc/oro-webpack-config-builder",
3
- "version": "5.1.0-alpha29",
3
+ "version": "5.1.0-alpha32",
4
4
  "author": "Oro, Inc (https://www.oroinc.com)",
5
5
  "license": "MIT",
6
6
  "description": "An integration of OroPlatform based applications with the Webpack.",
7
7
  "main": "oro-webpack-config.js",
8
8
  "dependencies": {
9
- "@babel/core": "^7.16.0",
10
- "@babel/plugin-transform-runtime": "^7.16.0",
11
- "@babel/preset-env": "^7.16.0",
12
- "autoprefixer": "^10.4.0",
13
- "babel-loader": "^8.2.3",
14
- "bindings": "^1.5.0",
15
- "css-loader": "^6.5.1",
16
- "css-minimizer-webpack-plugin": "^3.1.3",
17
- "deepmerge": "^4.2.2",
18
- "exports-loader": "^3.1.0",
19
- "expose-loader": "^3.1.0",
20
- "extract-loader": "^5.1.0",
21
- "file-loader": "^6.2.0",
22
- "happypack": "^5.0.1",
23
- "html-webpack-plugin": "^5.5.0",
24
- "imports-loader": "^3.1.1",
25
- "js-yaml": "^4.1.0",
26
- "mini-css-extract-plugin": "^2.4.4",
27
- "minimist": "^1.2.3",
28
- "nan": "^2.15.0",
9
+ "@babel/core": "~7.16.10",
10
+ "@babel/plugin-transform-runtime": "~7.16.10",
11
+ "@babel/preset-env": "~7.16.11",
12
+ "autoprefixer": "~10.4.0",
13
+ "babel-loader": "~8.2.3",
14
+ "bindings": "~1.5.0",
15
+ "css-loader": "~6.5.1",
16
+ "css-minimizer-webpack-plugin": "~3.4.1",
17
+ "deepmerge": "~4.2.2",
18
+ "exports-loader": "~3.1.0",
19
+ "expose-loader": "~3.1.0",
20
+ "extract-loader": "~5.1.0",
21
+ "file-loader": "~6.2.0",
22
+ "happypack": "~5.0.1",
23
+ "html-webpack-plugin": "~5.5.0",
24
+ "imports-loader": "~3.1.1",
25
+ "js-yaml": "~4.1.0",
26
+ "mini-css-extract-plugin": "~2.5.2",
27
+ "minimist": "~1.2.3",
28
+ "nan": "~2.15.0",
29
29
  "path": "0.12.7",
30
- "postcss": "^8.3.11",
31
- "postcss-loader": "^6.2.0",
32
- "printf": "^0.6.0",
33
- "resolve-url-loader": "^4.0.0",
34
- "rtlcss-webpack-plugin": "^4.0.6",
35
- "sass": "^1.43.4",
36
- "sass-loader": "^12.3.0",
37
- "style-loader": "^3.3.1",
38
- "terser": "^5.9.0",
30
+ "postcss": "~8.4.5",
31
+ "postcss-loader": "~6.2.0",
32
+ "printf": "~0.6.0",
33
+ "resolve-url-loader": "^5.0.0",
34
+ "rtlcss-webpack-plugin": "~4.0.6",
35
+ "sass": "~1.49.0",
36
+ "sass-loader": "~12.4.0",
37
+ "style-loader": "~3.3.1",
38
+ "terser": "~5.10.0",
39
39
  "text-loader": "0.0.1",
40
- "underscore": "^1.13.1",
41
- "url-loader": "^4.1.1",
42
- "webpack": "^5.63.0",
43
- "webpack-bundle-analyzer": "^4.5.0",
44
- "webpack-cli": "^4.9.1",
45
- "webpack-dev-server": "^4.4.0",
46
- "webpack-merge": "^5.8.0",
47
- "wildcard": "^2.0.0"
40
+ "underscore": "~1.13.1",
41
+ "url-loader": "~4.1.1",
42
+ "webpack": "~5.66.0",
43
+ "webpack-bundle-analyzer": "~4.5.0",
44
+ "webpack-cli": "~4.9.1",
45
+ "webpack-dev-server": "^4.7.3",
46
+ "webpack-merge": "~5.8.0",
47
+ "wildcard": "~2.0.0"
48
48
  }
49
49
  }
@@ -1,6 +1,7 @@
1
1
  const path = require('path');
2
2
  const wildcard = require('wildcard');
3
3
  const _ = require('underscore');
4
+ const messages = require('../messages')
4
5
 
5
6
  /**
6
7
  * @typedef ThemeGroupConfig
@@ -33,8 +34,13 @@ class StyleLoader {
33
34
  const writingOptions = {};
34
35
  for (const [group, config] of Object.entries(themeConfig)) {
35
36
  let {inputs, entries = [], output, auto_rtl_inputs: rtlMasks = []} = config;
36
- if (output === undefined) {
37
- throw new Error('"output" for "' + group + '" group in theme "' + theme + '" is not defined');
37
+
38
+ if (output === void 0) {
39
+ throw new Error(messages.assetsMissedOutput(group, theme));
40
+ }
41
+
42
+ if (inputs === void 0) {
43
+ throw new Error(messages.assetsMissedInput(group, theme));
38
44
  }
39
45
 
40
46
  inputs = this._overrideInputs(inputs);
@@ -1,3 +1,5 @@
1
+ const messages = require('./messages');
2
+
1
3
  class ThemeConfigFactory {
2
4
  /**
3
5
  * @param {ModulesConfigLoader} configLoader
@@ -17,7 +19,11 @@ class ThemeConfigFactory {
17
19
  * @return {Object} Merged Configs loaded from all the bundles Yaml files matched by filePath
18
20
  */
19
21
  loadConfig(theme, configFilepath) {
20
- return this._configLoader.loadConfig(theme, configFilepath);
22
+ try {
23
+ return this._configLoader.loadConfig(theme, configFilepath)
24
+ } catch (e) {
25
+ throw new Error(messages.jsModulesError(theme));
26
+ }
21
27
  }
22
28
 
23
29
  extendConfig(baseConfig, extraConfig) {
@@ -37,7 +43,7 @@ class ThemeConfigFactory {
37
43
 
38
44
  const beyondKeys = Object.keys(rest);
39
45
  if (beyondKeys.length) {
40
- throw new Error(`Sections ["${beyondKeys.join('", "')}"] are not allowed in extra js build definition`);
46
+ throw new Error( messages.jsExtraModulesError(beyondKeys));
41
47
  }
42
48
 
43
49
  return {