@oroinc/oro-webpack-config-builder 5.1.0-alpha45 β†’ 5.1.0-alpha47

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,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Justin Morris
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,54 @@
1
+ <div align="center">
2
+ <h3>πŸ’‰πŸ“¦<br><br><code>inject-loader</code></h3>
3
+ <h4>A Webpack loader for injecting code into modules via their dependencies</h4>
4
+ <a href="https://travis-ci.org/plasticine/inject-loader"><img src="https://img.shields.io/travis/plasticine/inject-loader/master.svg?style=flat-square" alt="build status" /></a> <a href="https://www.npmjs.com/package/inject-loader"><img src="https://img.shields.io/npm/v/inject-loader.svg?style=flat-square" alt="npm version" /></a> <a href="https://www.npmjs.com/package/inject-loader"><img src="https://img.shields.io/npm/dm/inject-loader.svg?style=flat-square" alt="npm downloads" /></a>
5
+ </div>
6
+
7
+ ***
8
+
9
+ ### Why
10
+
11
+ This is particularly useful for writing tests where mocking things inside your module-under-test is sometimes necessary before execution.
12
+
13
+ `inject-loader` was inspired by, and builds upon ideas introduced in [jauco/webpack-injectable](https://github.com/jauco/webpack-injectable).
14
+
15
+ ### Usage
16
+
17
+ [Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html)
18
+
19
+ Use the inject loader by adding the `inject-loader!` [inline loader](https://webpack.js.org/concepts/loaders/#inline) when you use `require`, this will return a function that can used in test code to modify the injected module.
20
+
21
+ By default all `require` statements in an injected module will be altered to be replaced with an injector, though if a replacement it not specified the default values will be used.
22
+
23
+ ### Examples
24
+
25
+ Given some code in a module like this:
26
+
27
+ ```javascript
28
+ // MyStore.js
29
+
30
+ var Dispatcher = require('lib/dispatcher');
31
+ var EventEmitter = require('events').EventEmitter;
32
+ var handleAction = require('lib/handle_action');
33
+
34
+ Dispatcher.register(handleAction, 'MyStore');
35
+ ```
36
+
37
+ You can manipulate it’s dependencies when you come to write tests as follows:
38
+
39
+ ```javascript
40
+ // If no flags are provided when using the loader then
41
+ // all require statements will be wrapped in an injector
42
+ MyModuleInjector = require('inject-loader!MyStore')
43
+ MyModule = MyModuleInjector({
44
+ 'lib/dispatcher': DispatcherMock,
45
+ 'events': EventsMock,
46
+ 'lib/handle_action': HandleActionMock
47
+ })
48
+ ```
49
+
50
+ There are a few examples of complete test setups for both Webpack 1, 2, 3 & 4 in the [`example`](./example) folder.
51
+
52
+ ## License
53
+
54
+ MIT (http://www.opensource.org/licenses/mit-license.php)
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "inject-loader",
3
+ "version": "4.0.1",
4
+ "description": "A Webpack loader for injecting code into modules via their dependencies",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "build": "webpack --config config/webpack.config.js",
8
+ "build:test": "webpack --config config/webpack.test.config.js",
9
+ "build:release": "yarn run build && mkdir -p ./dist && cp -f ./tmp/index.js ./dist/index.js && cp -f ./tmp/index.js.map ./dist/index.js.map",
10
+ "pretest:unit": "yarn build && yarn build:test",
11
+ "test:unit": "mocha tmp/testBundle.js --require source-map-support/register",
12
+ "test:integration": "./script/integration_test",
13
+ "test": "flow && yarn test:unit && yarn test:integration",
14
+ "precommit": "pretty-quick --staged"
15
+ },
16
+ "files": [
17
+ "*.md",
18
+ "dist"
19
+ ],
20
+ "author": "Justin Morris <desk@pixelbloom.com> (http://pixelbloom.com)",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git@github.com:plasticine/inject-loader.git"
24
+ },
25
+ "license": "MIT",
26
+ "dependencies": {
27
+ "babel-core": "~6"
28
+ },
29
+ "devDependencies": {
30
+ "babel-loader": "^7.1.4",
31
+ "babel-plugin-add-module-exports": "^0.2.1",
32
+ "babel-plugin-transform-flow-strip-types": "^6.22.0",
33
+ "babel-preset-es2015": "^6.22.0",
34
+ "flow-bin": "^0.69.0",
35
+ "husky": "^0.14.3",
36
+ "mocha": "^5.0.5",
37
+ "prettier": "^1.11.1",
38
+ "pretty-quick": "^1.4.1",
39
+ "source-map-support": "^0.5.4",
40
+ "webpack": "^4.35.0",
41
+ "webpack-cli": "^3.3.5"
42
+ },
43
+ "peerDependencies": {
44
+ "webpack": "^1 || ^2 || ^3 || ^4"
45
+ },
46
+ "keywords": [
47
+ "webpack",
48
+ "testing",
49
+ "loader",
50
+ "webpack-loader",
51
+ "inject",
52
+ "mock",
53
+ "mocking"
54
+ ]
55
+ }
@@ -8,7 +8,7 @@ class LayoutModulesConfigLoader extends ModulesConfigLoader {
8
8
  */
9
9
  loadConfig(theme, filePath) {
10
10
  let themeConfig = super.loadConfig(theme, path.join('Resources/views/layouts/', theme, filePath));
11
- themeConfig = merge(themeConfig, super.loadConfig(theme, path.join('templates/layouts/', theme, filePath)));
11
+
12
12
  // recursive process parent theme
13
13
  const {parent: parentTheme} = this.themes[theme];
14
14
  if (typeof parentTheme === 'string') {
@@ -38,34 +38,24 @@ class ModulesConfigLoader {
38
38
 
39
39
  /**
40
40
  * @param {Array} bundles Array of ordered symfony bundle paths
41
- * @param {string|Array} themesLocation Path inside the bundle, where to find the theme
41
+ * @param {string} themesLocation Path inside the bundle, where to find the theme
42
42
  * @param {string} themeInfoFileName Yaml File name with theme info
43
43
  */
44
44
  constructor(bundles, themesLocation, themeInfoFileName) {
45
45
  this._bundles = bundles;
46
- if (!Array.isArray(themesLocation)) {
47
- themesLocation = [themesLocation];
48
- }
49
-
50
- const themes = {};
51
- const self = this;
52
- themesLocation.forEach(themesLocation => {
53
- self._collectThemes(themes, themesLocation, themeInfoFileName);
54
- });
55
-
56
- this._themes = themes;
46
+ this._themes = this._getThemes(themesLocation, themeInfoFileName);
57
47
  this._processedFiles = [];
58
48
  }
59
49
 
60
50
  /**
61
- * Collects list of themes with their parents into given storage(themes param)
62
- *
63
- * @param {Object} themes
51
+ * Return list of themes with their parents
64
52
  * @param {string} themesLocation
65
53
  * @param {string} themeInfoFileName
54
+ * @returns {Object.<string|null>}
66
55
  * @private
67
56
  */
68
- _collectThemes(themes, themesLocation, themeInfoFileName) {
57
+ _getThemes(themesLocation, themeInfoFileName) {
58
+ const themes = {};
69
59
  this._bundles.forEach(bundle => {
70
60
  const source = bundle + themesLocation;
71
61
 
@@ -83,6 +73,8 @@ class ModulesConfigLoader {
83
73
  themes[name] = merge(themes[name] || {}, theme, {arrayMerge});
84
74
  });
85
75
  });
76
+
77
+ return themes;
86
78
  }
87
79
 
88
80
  /**
@@ -10,6 +10,7 @@ const LayoutModulesConfigLoader = require('./modules-config/layout-modules-confi
10
10
  const LayoutStyleLoader = require('./style/layout-style-loader');
11
11
  const MapModulesPlugin = require('./plugin/map/map-modules-plugin');
12
12
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
13
+ const HappyPack = require('happypack');
13
14
  const ModulesConfigLoader = require('./modules-config/modules-config-loader');
14
15
  const DynamicImportsFileWriter = require('./writer/dynamic-imports-file-writer');
15
16
  const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
@@ -31,7 +32,6 @@ require('resolve-url-loader');
31
32
 
32
33
  class ConfigBuilder {
33
34
  constructor() {
34
- this._projectPath = '';
35
35
  this._enableLayoutThemes = false;
36
36
  this._defaultLayoutThemes = null;
37
37
  this.emitter = new EventEmitter();
@@ -186,13 +186,6 @@ class ConfigBuilder {
186
186
  };
187
187
  }
188
188
 
189
- get resolvedProjectPath() {
190
- if (this._resolvedProjectPath == undefined) {
191
- this._resolvedProjectPath = path.resolve(this._projectPath);
192
- }
193
- return this._resolvedProjectPath;
194
- }
195
-
196
189
  get resolvedPublicPath() {
197
190
  if (this._resolvedPublicPath === undefined) {
198
191
  this._resolvedPublicPath = path.resolve(this._publicPath);
@@ -331,7 +324,6 @@ class ConfigBuilder {
331
324
  }, {
332
325
  loader: 'sass-loader',
333
326
  options: {
334
- implementation: require("sass"),
335
327
  sassOptions: {
336
328
  includePaths: [
337
329
  path.join(this.resolvedPublicPath, '/bundles')
@@ -379,7 +371,19 @@ class ConfigBuilder {
379
371
  webpackConfig.plugins.push(new BundleAnalyzerPlugin());
380
372
  }
381
373
 
382
- if (!env.skipJS && env.withBabel) {
374
+ if (!env.skipJS && !env.skipBabel) {
375
+ const happyPackOptions = {
376
+ id: 'babel',
377
+ loaders: [
378
+ {
379
+ loader: 'babel-loader',
380
+ options: this._babelConfig
381
+ }
382
+ ]
383
+ };
384
+
385
+ webpackConfig.plugins.push(new HappyPack(happyPackOptions));
386
+
383
387
  webpackConfig.module.rules.push({
384
388
  test: /\.js$/,
385
389
  exclude: [
@@ -387,10 +391,7 @@ class ConfigBuilder {
387
391
  /[\/\\]node_modules[\/\\]/,
388
392
  /[\/\\]bundles[\/\\].+[\/\\]lib[\/\\]?/
389
393
  ],
390
- use: {
391
- loader: 'babel-loader',
392
- options: this._babelConfig
393
- }
394
+ use: 'happypack/loader?id=babel'
394
395
  });
395
396
  }
396
397
 
@@ -432,14 +433,9 @@ class ConfigBuilder {
432
433
  if (this._isAdminTheme(buildName)) {
433
434
  themeDefinition = this._modulesConfigLoader.themes[buildName.split('.')[1]];
434
435
  buildPublicPath = '/build/admin/';
435
- const jsModulesConfig = this._themeConfigFactory.loadConfig(
436
- buildName,
437
- [
438
- 'Resources/config/oro/jsmodules.yml',
439
- 'Resources/config/jsmodules.yml',
440
- 'config/oro/jsmodules.yml'
441
- ]
442
- ); validation.jsmodulesValidator.checkFullSchema(
436
+ const jsModulesConfig = this._themeConfigFactory.loadConfig(buildName,
437
+ ['Resources/config/oro/jsmodules.yml', 'Resources/config/jsmodules.yml']);
438
+ validation.jsmodulesValidator.checkFullSchema(
443
439
  jsModulesConfig,
444
440
  this._themeConfigFactory?._configLoader.processedFiles,
445
441
  buildName
@@ -477,7 +473,6 @@ class ConfigBuilder {
477
473
  modules: [
478
474
  resolvedBuildPath,
479
475
  this.resolvedPublicPath,
480
- path.join(this.resolvedProjectPath, '/assets'),
481
476
  path.join(this.resolvedPublicPath, '/bundles'),
482
477
  path.join(this.resolvedPublicPath, '/js'),
483
478
  this.resolvedNodeModulesPath
@@ -542,11 +537,10 @@ class ConfigBuilder {
542
537
  this._isProduction = args.mode === 'production';
543
538
  this._symfonyEnv = env.symfony;
544
539
  this._appConfig = AppConfigLoader.getConfig(this._cachePath, this._symfonyEnv);
545
- this._appConfig.paths.push(this.resolvedProjectPath);
546
540
 
547
541
  this._modulesConfigLoader = new ModulesConfigLoader(
548
542
  this._appConfig.paths,
549
- ['/Resources/public/themes/', '/public/themes/admin/'],
543
+ '/Resources/public/themes/',
550
544
  'settings.yml'
551
545
  );
552
546
  this._adminThemes = this._modulesConfigLoader.themeNames.map(themeName => 'admin.' + themeName);
@@ -560,7 +554,7 @@ class ConfigBuilder {
560
554
 
561
555
  this._layoutModulesConfigLoader = new LayoutModulesConfigLoader(
562
556
  this._appConfig.paths,
563
- ['/Resources/views/layouts/', '/templates/layouts/'],
557
+ '/Resources/views/layouts/',
564
558
  'theme.yml'
565
559
  );
566
560
  this._layoutStyleLoader = new LayoutStyleLoader(this._layoutModulesConfigLoader, entryPointFileWriter);
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@oroinc/oro-webpack-config-builder",
3
- "version": "5.1.0-alpha45",
3
+ "version": "5.1.0-alpha47",
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.20.5",
10
- "@babel/plugin-transform-runtime": "~7.19.6",
9
+ "@babel/core": "^7.20.12",
10
+ "@babel/plugin-transform-runtime": "^7.19.6",
11
11
  "@babel/preset-env": "~7.20.2",
12
- "autoprefixer": "~10.4.13",
13
- "babel-loader": "~9.1.0",
12
+ "autoprefixer": "^10.4.13",
13
+ "babel-loader": "~8.2.3",
14
14
  "bindings": "~1.5.0",
15
15
  "css-loader": "^6.7.3",
16
16
  "css-minimizer-webpack-plugin": "~4.2.2",
@@ -18,29 +18,30 @@
18
18
  "exports-loader": "~4.0.0",
19
19
  "expose-loader": "~4.0.0",
20
20
  "file-loader": "~6.2.0",
21
+ "happypack": "~5.0.1",
21
22
  "html-webpack-plugin": "~5.5.0",
22
- "imports-loader": "~4.0.1",
23
+ "imports-loader": "~4.0.0",
23
24
  "js-yaml": "~4.1.0",
24
- "mini-css-extract-plugin": "~2.7.1",
25
- "minimist": "~1.2.7",
26
- "nan": "~2.17.0",
25
+ "mini-css-extract-plugin": "^2.7.1",
26
+ "minimist": "^1.2.7",
27
+ "nan": "^2.17.0",
27
28
  "path": "0.12.7",
28
29
  "postcss": "~8.4.19",
29
- "postcss-loader": "~7.0.2",
30
+ "postcss-loader": "^7.0.2",
30
31
  "printf": "~0.6.0",
31
32
  "resolve-url-loader": "^5.0.0",
32
33
  "rtlcss-webpack-plugin": "~4.0.6",
33
- "sass": "~1.56.1",
34
+ "sass": "^1.57.1",
34
35
  "sass-loader": "~13.2.0",
35
36
  "schema-utils": "^4.0.0",
36
37
  "style-loader": "~3.3.1",
37
- "terser": "~5.16.1",
38
+ "terser": "^5.16.1",
38
39
  "text-loader": "0.0.1",
39
- "underscore": "1.13.*",
40
- "url-loader": "~4.1.1",
41
- "webpack": "~5.75.0",
42
- "webpack-bundle-analyzer": "~4.7.0",
43
- "webpack-cli": "~5.0.0",
40
+ "underscore": "^1.13.6",
41
+ "url-loader": "^4.1.1",
42
+ "webpack": "^5.75.0",
43
+ "webpack-bundle-analyzer": "^4.7.0",
44
+ "webpack-cli": "~4.9.1",
44
45
  "webpack-dev-server": "^4.11.1",
45
46
  "webpack-merge": "~5.8.0",
46
47
  "wildcard": "~2.0.0"
@@ -9,9 +9,8 @@ class AdminStyleLoader extends StyleLoader {
9
9
  const {rtl_support: rtlSupport = false, styles: extraThemeConfig} =
10
10
  this._configLoader.loadConfig(themeName, 'Resources/public/themes/' + themeName + '/settings.yml');
11
11
  const baseThemeConfig = this._configLoader.loadConfig(themeName, 'Resources/config/oro/assets.yml');
12
- const appRootExtraConfig = this._configLoader.loadConfig(themeName, 'config/oro/assets.yml');
13
12
  /** @type {Object.<string, ThemeGroupConfig>} */
14
- const themeConfig = merge(baseThemeConfig, appRootExtraConfig, extraThemeConfig);
13
+ const themeConfig = merge(baseThemeConfig, extraThemeConfig);
15
14
 
16
15
  return {
17
16
  themeConfig,
@@ -49,7 +49,6 @@ class StyleLoader {
49
49
 
50
50
  inputs = this._overrideInputs(inputs);
51
51
  inputs = this._sortInputs(inputs);
52
- inputs = this._applyInputsBasePathPrefix(inputs);
53
52
 
54
53
  if (settings.rtlSupport) {
55
54
  writingOptions.ignoreRTLInputs = _.difference(inputs, this._matchInputs(rtlMasks, inputs));
@@ -59,7 +58,7 @@ class StyleLoader {
59
58
  const filePath = path.join(buildPath, output);
60
59
  entryPoints[entryPointName] = [
61
60
  ...entries,
62
- this._entryPointFileWriter.write('./../../', inputs, filePath, writingOptions)
61
+ this._entryPointFileWriter.write('./../../../', inputs, filePath, writingOptions)
63
62
  ];
64
63
  }
65
64
  return entryPoints;
@@ -154,7 +153,6 @@ class StyleLoader {
154
153
  * @protected
155
154
  */
156
155
  _matchInputs(masks, inputs) {
157
- masks = this._applyInputsBasePathPrefix(masks);
158
156
  masks = masks.map(mask => wildcard(mask));
159
157
 
160
158
  const whiteListedInputs = masks.reduce((include, mask) => {
@@ -164,26 +162,6 @@ class StyleLoader {
164
162
 
165
163
  return _.unique(whiteListedInputs);
166
164
  }
167
-
168
- /**
169
- * Considering base path as application's root.
170
- * Bundles based *.scss sources go with '../' prefix.
171
- *
172
- * @param {string[]} inputs
173
- * @private
174
- */
175
- _applyInputsBasePathPrefix(inputs) {
176
- const processedInputs = [];
177
-
178
- inputs.forEach(input => {
179
- if (input.indexOf('bundles') === 0) {
180
- input = '../' + input;
181
- }
182
- processedInputs.push(input);
183
- });
184
-
185
- return processedInputs;
186
- }
187
165
  }
188
166
 
189
167
  module.exports = StyleLoader;
@@ -82,11 +82,10 @@ module.exports = Object.assign({}, schemaValidator, {
82
82
  input = newPath;
83
83
  }
84
84
 
85
- const fullBasePath = path.resolve(input);
86
85
  const fullPath = path.resolve(this._publicPath + input);
87
86
  // skip the path to global node modules,
88
87
  // e.g. '~bootstrap/scss/bootstrap'
89
- if (!input.startsWith('~') && !fs.existsSync(fullPath) && !fs.existsSync(fullBasePath)) {
88
+ if (!input.startsWith('~') && !fs.existsSync(fullPath)) {
90
89
  files.push(input);
91
90
  }
92
91
  });