@oroinc/oro-webpack-config-builder 5.1.0-alpha9 → 5.1.0-lts001
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.
- package/README.md +1 -1
- package/error-handler.js +95 -0
- package/loader/config-loader.js +1 -2
- package/loader/inject-loader/LICENSE.md +21 -0
- package/loader/inject-loader/README.md +54 -0
- package/loader/inject-loader/index.js +10 -0
- package/loader/inject-loader/injectify.js +66 -0
- package/loader/inject-loader/package.json +55 -0
- package/loader/inject-loader/wrapper_template.js +32 -0
- package/modules-config/layout-modules-config-loader.js +66 -2
- package/modules-config/modules-config-loader.js +52 -19
- package/oro-webpack-config.js +410 -299
- package/package.json +37 -38
- package/plugin/logs/after-webpack-logs-plugin.js +25 -0
- package/style/admin-style-loader.js +4 -3
- package/style/layout-style-loader.js +3 -3
- package/style/style-loader.js +52 -7
- package/theme-config-factory.js +45 -6
- package/utils.js +30 -0
- package/validation/assets-validator.js +104 -0
- package/validation/errors/assets-input-file-error.js +24 -0
- package/validation/errors/assets-schema-error.js +40 -0
- package/validation/errors/base-error.js +37 -0
- package/validation/errors/jsmodules-extra-modules-error.js +22 -0
- package/validation/errors/jsmodules-schema-error.js +40 -0
- package/validation/errors/styles-error.js +24 -0
- package/validation/index.js +36 -0
- package/validation/jsmodules-validator.js +53 -0
- package/validation/schema-validator.js +62 -0
- package/validation/schemas/assets-schema-full.js +22 -0
- package/validation/schemas/assets-schema.js +32 -0
- package/validation/schemas/jsmodules-schema-full.js +11 -0
- package/validation/schemas/jsmodules-schema.js +76 -0
- package/writer/configs-file-writer.js +1 -1
- package/writer/dynamic-imports-file-writer.js +3 -3
- package/writer/scss-entry-point-file-writer.js +1 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const BaseError = require('./base-error');
|
|
2
|
+
|
|
3
|
+
class StylesError extends BaseError {
|
|
4
|
+
/**
|
|
5
|
+
* @example
|
|
6
|
+
* Failed assembly styles: the "output" for "styles" entry point in "default" theme is not defined.
|
|
7
|
+
* Please, find more information in the documentation https://doc.oroinc.com/...
|
|
8
|
+
*
|
|
9
|
+
* @param {string} key
|
|
10
|
+
* @param {string} group
|
|
11
|
+
* @param {string} theme
|
|
12
|
+
*/
|
|
13
|
+
constructor(key, group, theme) {
|
|
14
|
+
const msg = `the "${key}" for "${group}" entry point in "${theme}" theme is not defined.`;
|
|
15
|
+
|
|
16
|
+
super(msg);
|
|
17
|
+
|
|
18
|
+
this.name = 'Failed assembly styles';
|
|
19
|
+
this.docLink =
|
|
20
|
+
'https://doc.oroinc.com/backend/bundles/platform/AssetBundle/#load-scss-or-css-files-from-the-bundle';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = StylesError;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const assetsValidation = require('./assets-validator');
|
|
2
|
+
const jsmodulesValidator = require('./jsmodules-validator');
|
|
3
|
+
|
|
4
|
+
const isJSModulesPath = path => /jsmodules([-a-zA-Z\d]*)\.yml$/.test(path);
|
|
5
|
+
const isAssetsPath = path => /assets\.yml$/.test(path);
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
assetsValidation,
|
|
9
|
+
jsmodulesValidator,
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* set public path for all validators
|
|
13
|
+
* {string} path
|
|
14
|
+
*/
|
|
15
|
+
setPublicPath(path) {
|
|
16
|
+
[assetsValidation, jsmodulesValidator].forEach(validator => validator.setPublicPath(path));
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Run appropriate validator
|
|
21
|
+
* {string} filePath
|
|
22
|
+
* {Object} doc
|
|
23
|
+
* {string} theme
|
|
24
|
+
*/
|
|
25
|
+
checkSchema(filePath, doc, theme) {
|
|
26
|
+
if (isJSModulesPath(filePath)) {
|
|
27
|
+
jsmodulesValidator.checkSchema(filePath, doc, theme);
|
|
28
|
+
} else if (isAssetsPath(filePath)) {
|
|
29
|
+
const validSchema = assetsValidation.checkSchema(filePath, doc, theme);
|
|
30
|
+
|
|
31
|
+
if (validSchema) {
|
|
32
|
+
assetsValidation.checkInputsExist(filePath, doc, theme);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const schema = require('./schemas/jsmodules-schema');
|
|
2
|
+
const fullSchema = require('./schemas/jsmodules-schema-full');
|
|
3
|
+
const schemaValidator = require('./schema-validator');
|
|
4
|
+
const {isProdMode} = require('../utils');
|
|
5
|
+
const EventEmitter = require('events');
|
|
6
|
+
const emitter = new EventEmitter();
|
|
7
|
+
const JSModulesSchemaError = require('./errors/jsmodules-schema-error');
|
|
8
|
+
|
|
9
|
+
module.exports = Object.assign({}, schemaValidator, {
|
|
10
|
+
emitter,
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @param {string} filePath
|
|
14
|
+
* @param {Object} doc
|
|
15
|
+
* @param {string} theme
|
|
16
|
+
* @returns {boolean|undefined}
|
|
17
|
+
*/
|
|
18
|
+
checkSchema(filePath, doc, theme) {
|
|
19
|
+
if (isProdMode()) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const result = this.validateSchema(schema, doc);
|
|
23
|
+
|
|
24
|
+
if (!result.valid) {
|
|
25
|
+
const error = new JSModulesSchemaError(result.formattedError, [filePath], theme);
|
|
26
|
+
|
|
27
|
+
this.emitter.emit('error', error);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return result.valid;
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @param {Object} doc
|
|
35
|
+
* @param {Array} files
|
|
36
|
+
* @param {string} theme
|
|
37
|
+
* @returns {boolean|undefined}
|
|
38
|
+
*/
|
|
39
|
+
checkFullSchema(doc, files = [], theme) {
|
|
40
|
+
if (isProdMode()) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const result = this.validateSchema(fullSchema, doc);
|
|
44
|
+
|
|
45
|
+
if (!result.valid) {
|
|
46
|
+
const error = new JSModulesSchemaError(result.formattedError, files, theme);
|
|
47
|
+
|
|
48
|
+
this.emitter.emit('error', error);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return result.valid;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const {validate} = require('schema-utils');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
/**
|
|
5
|
+
* Symfony public directory path related to application root folder
|
|
6
|
+
* {string}
|
|
7
|
+
*/
|
|
8
|
+
_publicPath: 'public/',
|
|
9
|
+
|
|
10
|
+
setPublicPath(path) {
|
|
11
|
+
this._publicPath = path;
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Validates data according to the schema
|
|
16
|
+
* @param {Object} scheme
|
|
17
|
+
* @param {Object} data
|
|
18
|
+
* @param {Object} [options]
|
|
19
|
+
* @returns {Object}
|
|
20
|
+
*/
|
|
21
|
+
validateSchema(scheme, data, options) {
|
|
22
|
+
const result = {
|
|
23
|
+
valid: true
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
const baseDataPath = 'configuration';
|
|
28
|
+
const basePathReg = /^configuration\./;
|
|
29
|
+
validate(scheme, data, {
|
|
30
|
+
baseDataPath,
|
|
31
|
+
...options || {},
|
|
32
|
+
postFormatter(formattedError, error) {
|
|
33
|
+
if (result.formattedError === void 0) {
|
|
34
|
+
result.formattedError = [];
|
|
35
|
+
}
|
|
36
|
+
result.error = error;
|
|
37
|
+
|
|
38
|
+
if (
|
|
39
|
+
Array.isArray(error.params.type) ||
|
|
40
|
+
error.params.missingProperty
|
|
41
|
+
) {
|
|
42
|
+
// remove an excess line break
|
|
43
|
+
formattedError = formattedError.replace(/\n/g, ' ');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
formattedError = formattedError.replace(basePathReg, '');
|
|
47
|
+
result.formattedError.push(formattedError.trim());
|
|
48
|
+
return formattedError;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
} catch (e) {
|
|
52
|
+
result.valid = false;
|
|
53
|
+
result.errorMessage = e.message;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (result.formattedError) {
|
|
57
|
+
result.formattedError = result.formattedError.join('\n');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema to validate assets.yml files
|
|
3
|
+
*
|
|
4
|
+
* @description
|
|
5
|
+
* Full scheme complements "assets-schema" one.
|
|
6
|
+
* It should have only rules which are not defined in "assets-schema" schema due to avoid duplicates in error messages
|
|
7
|
+
*/
|
|
8
|
+
module.exports = {
|
|
9
|
+
type: 'object',
|
|
10
|
+
patternProperties: {
|
|
11
|
+
'.*': {
|
|
12
|
+
type: 'object',
|
|
13
|
+
properties: {
|
|
14
|
+
inputs: {
|
|
15
|
+
description: 'The "inputs" property is an array of files to load.',
|
|
16
|
+
minItems: 1
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
required: ['inputs', 'output']
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema to validate assets.yml files
|
|
3
|
+
*/
|
|
4
|
+
module.exports = {
|
|
5
|
+
type: 'object',
|
|
6
|
+
patternProperties: {
|
|
7
|
+
'.*': {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
inputs: {
|
|
11
|
+
description: 'The "inputs" property is an array of files to load.',
|
|
12
|
+
type: 'array',
|
|
13
|
+
items: {
|
|
14
|
+
type: ['string', 'object']
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
output: {
|
|
18
|
+
description: 'Output file path inside "public/" directory for the entry point',
|
|
19
|
+
type: 'string'
|
|
20
|
+
},
|
|
21
|
+
auto_rtl_inputs: {
|
|
22
|
+
description: 'List of wildcard file masks for inputs that has to be processed with RTL plugin.',
|
|
23
|
+
type: 'array',
|
|
24
|
+
items: {
|
|
25
|
+
type: 'string'
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
additionalProperties: false
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema to validate jsmodules.yml files
|
|
3
|
+
*
|
|
4
|
+
* @description
|
|
5
|
+
* Full scheme complements "jsmodules-schema" one.
|
|
6
|
+
* It should have only rules which are not defined in "jsmodules-schema" schema due to avoid duplicates in error messages
|
|
7
|
+
*/
|
|
8
|
+
module.exports = {
|
|
9
|
+
type: 'object',
|
|
10
|
+
required: ['entry']
|
|
11
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema to validate jsmodules.yml files
|
|
3
|
+
*/
|
|
4
|
+
module.exports = {
|
|
5
|
+
type: 'object',
|
|
6
|
+
properties: {
|
|
7
|
+
'entry': {
|
|
8
|
+
description: 'Webpack entry points configuration.',
|
|
9
|
+
type: 'object',
|
|
10
|
+
patternProperties: {
|
|
11
|
+
'.*': {
|
|
12
|
+
type: 'array',
|
|
13
|
+
items: {
|
|
14
|
+
type: 'string'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
'shim': {
|
|
20
|
+
description: 'Configure a webpack shimming feature',
|
|
21
|
+
type: 'object',
|
|
22
|
+
patternProperties: {
|
|
23
|
+
'.*': {
|
|
24
|
+
type: 'object'
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
'map': {
|
|
29
|
+
description: 'The map option allows to substitute a module with the given ID with a different module.',
|
|
30
|
+
type: 'object',
|
|
31
|
+
patternProperties: {
|
|
32
|
+
'.*': {
|
|
33
|
+
type: 'object'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
'app-modules': {
|
|
38
|
+
description: 'Introduces a list of modules that should be initialized before application is launched.',
|
|
39
|
+
type: 'array',
|
|
40
|
+
items: {
|
|
41
|
+
type: 'string'
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
'dynamic-imports': {
|
|
45
|
+
description: 'Gives possibility to import a module with the name that is determined at runtime.',
|
|
46
|
+
type: 'object',
|
|
47
|
+
patternProperties: {
|
|
48
|
+
'.*': {
|
|
49
|
+
type: 'array',
|
|
50
|
+
items: {
|
|
51
|
+
type: 'string'
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
'configs': {
|
|
57
|
+
description: 'Runtime configuration for a the module.',
|
|
58
|
+
type: 'object',
|
|
59
|
+
patternProperties: {
|
|
60
|
+
'.*': {
|
|
61
|
+
type: 'object'
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
'aliases': {
|
|
66
|
+
description: 'An alias is an alternative name.',
|
|
67
|
+
type: 'object',
|
|
68
|
+
patternProperties: {
|
|
69
|
+
'.*': {
|
|
70
|
+
type: 'string'
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
additionalProperties: false
|
|
76
|
+
};
|
|
@@ -12,7 +12,7 @@ class ConfigsFileWriter {
|
|
|
12
12
|
/**
|
|
13
13
|
* Write app-modules.js file and return file path
|
|
14
14
|
*
|
|
15
|
-
* @param {
|
|
15
|
+
* @param {Object} configs List of configurable modules
|
|
16
16
|
* @param {string} output Output file path
|
|
17
17
|
* @returns {string} JS file path of an output file
|
|
18
18
|
*/
|
|
@@ -19,9 +19,9 @@ class DynamicImportsFileWriter {
|
|
|
19
19
|
write(dynamicImports, output) {
|
|
20
20
|
const buildPath = path.join(output, 'dynamic-imports.js');
|
|
21
21
|
let content = Object.entries(dynamicImports).map(([chunkName, moduleNames]) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
);
|
|
22
|
+
const notation = chunkName === 'commons'
|
|
23
|
+
? '/* webpackMode: "eager" */' : `/* webpackChunkName: "${chunkName}" */`;
|
|
24
|
+
return moduleNames.map(moduleName =>`'${moduleName}': () => import(${notation}'${moduleName}')`);
|
|
25
25
|
});
|
|
26
26
|
content = `module.exports = {\n ${content.flat().join(',\n ')}\n};\n`;
|
|
27
27
|
const filepath = path.resolve(this._publicPath + buildPath);
|
|
@@ -25,7 +25,7 @@ class SCSSEntryPointFileWriter {
|
|
|
25
25
|
input = input.replace(/\.[^/.]+$/, '');
|
|
26
26
|
// don't add the base path to global node modules,
|
|
27
27
|
// e.g. '~bootstrap/scss/bootstrap'
|
|
28
|
-
const basePath = input.startsWith('~') ? '': baseInputPath;
|
|
28
|
+
const basePath = input.startsWith('~') ? '' : baseInputPath;
|
|
29
29
|
let importModule = `@import "${basePath}${input}";\n`;
|
|
30
30
|
if (ignoreRTL) {
|
|
31
31
|
importModule = `/*rtl:begin:ignore*/\n${importModule}/*rtl:end:ignore*/\n`;
|