@rws-framework/client 2.8.4 → 2.9.0

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.
Files changed (38) hide show
  1. package/cfg/_default.cfg.js +1 -0
  2. package/cfg/build_steps/webpack/_aliases.js +10 -0
  3. package/cfg/build_steps/webpack/_info.js +19 -0
  4. package/cfg/build_steps/webpack/_loaders.js +40 -0
  5. package/cfg/build_steps/webpack/_rws_externals.js +66 -0
  6. package/cfg/tsconfigSetup.js +30 -10
  7. package/foundation/index.js +1 -0
  8. package/foundation/rws-foundation.d.ts +8 -0
  9. package/foundation/rws-foundation.js +8 -0
  10. package/package.json +6 -4
  11. package/rws.webpack.config.js +137 -131
  12. package/service_worker/src/_service_worker.ts +1 -1
  13. package/src/client/config.ts +10 -3
  14. package/src/client.ts +3 -2
  15. package/src/components/_attrs/external-observable.ts +72 -0
  16. package/src/components/_component.ts +4 -5
  17. package/src/components/_container.ts +4 -4
  18. package/src/components/_decorator.ts +39 -9
  19. package/src/components/_decorators/RWSFillBuild.ts +0 -1
  20. package/src/components/_decorators/RWSInject.ts +3 -3
  21. package/src/components/_decorators/_di.ts +2 -2
  22. package/src/components/loader/styles/layout.scss +5 -5
  23. package/src/index.d.ts +1 -0
  24. package/src/index.ts +5 -5
  25. package/src/plugins/_plugin.ts +1 -1
  26. package/src/services/ConfigService.ts +4 -4
  27. package/src/services/_service.ts +10 -7
  28. package/src/types/RWSWindow.ts +2 -1
  29. package/tsconfig.json +5 -1
  30. package/types/declarations.d.ts +1 -1
  31. package/webpack/loaders/rws_fast_scss_loader.js +39 -30
  32. package/webpack/loaders/rws_fast_ts_loader.js +5 -3
  33. package/webpack/rws_after_plugin.js +26 -23
  34. package/webpack/rws_scss_plugin.js +22 -11
  35. package/_rws_externals.js +0 -39
  36. package/src/components/_design_system.ts +0 -6
  37. package/webpack/loaders/rws_fast_html_loader.js +0 -8
  38. package/webpack/loaders/rws_uncomments_loader.js +0 -35
@@ -17,6 +17,7 @@ const _DEFAULT_CONFIG_VARS = {
17
17
  //Universal configs
18
18
  transports: ['websocket'],
19
19
  parted: false,
20
+ plugins: []
20
21
  }
21
22
 
22
23
  const _DEFAULT_CONFIG = Object.freeze(_DEFAULT_CONFIG_VARS);
@@ -0,0 +1,10 @@
1
+ const path = require('path');
2
+
3
+ function loadAliases(packageDir, nodeModulesPath){
4
+ return {
5
+ fs: false,
6
+ '@rws-framework/foundation': path.resolve(packageDir, 'foundation', 'rws-foundation.js')
7
+ }
8
+ }
9
+
10
+ module.exports = { loadAliases }
@@ -0,0 +1,19 @@
1
+ const chalk = require('chalk');
2
+
3
+ module.exports = {
4
+ start: (executionDir, tsConfigPath, outputDir, isDev, publicDir, isParted, partedPrefix, partedDirUrlPrefix, devTools, rwsPlugins) => {
5
+ console.log(chalk.green('Build started with'))
6
+ console.log({
7
+ executionDir,
8
+ tsConfigPath,
9
+ outputDir,
10
+ dev: isDev,
11
+ publicDir,
12
+ parted: isParted,
13
+ partedPrefix,
14
+ partedDirUrlPrefix,
15
+ devtool: devTools,
16
+ plugins: rwsPlugins
17
+ });
18
+ }
19
+ }
@@ -0,0 +1,40 @@
1
+ const path = require('path');
2
+
3
+ function getRWSLoaders(packageDir, nodeModulesPath, tsConfigPath){
4
+ console.log(packageDir, nodeModulesPath, tsConfigPath);
5
+
6
+ const scssLoader = packageDir + '/webpack/loaders/rws_fast_scss_loader.js';
7
+ const tsLoader = packageDir + '/webpack/loaders/rws_fast_ts_loader.js';
8
+ const htmlLoader = packageDir + '/webpack/loaders/rws_fast_html_loader.js';
9
+
10
+ return [
11
+ {
12
+ test: /\.scss$/,
13
+ use: [
14
+ scssLoader,
15
+ ],
16
+ },
17
+ {
18
+ test: /\.(ts)$/,
19
+ use: [
20
+ {
21
+ loader: 'ts-loader',
22
+ options: {
23
+ allowTsInNodeModules: true,
24
+ configFile: path.resolve(tsConfigPath)
25
+ }
26
+ },
27
+ {
28
+ loader: tsLoader,
29
+ }
30
+ ],
31
+ exclude: [
32
+ /node_modules\/(?!\@rws-framework\/[A-Z0-9a-z])/,
33
+ /\.debug\.ts$/,
34
+ /\.d\.ts$/,
35
+ ],
36
+ }
37
+ ]
38
+ }
39
+
40
+ module.exports = { getRWSLoaders }
@@ -0,0 +1,66 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const tools = require('../../../_tools');
4
+
5
+ const frontendRequestContextCache = [];
6
+
7
+ const _defaultOpts = {
8
+ _vars: {
9
+ packed: [],
10
+ ignored: [],
11
+ frontendRequestContextCache
12
+ }
13
+ }
14
+
15
+ const externals = (declaredCodeBase, nodeModules, externalOptions = _defaultOpts) => ({context, request}, callback) => {
16
+ let theOptions = _defaultOpts;
17
+
18
+ if(externalOptions !== null){
19
+ theOptions = Object.assign(theOptions, externalOptions);
20
+ }
21
+
22
+ const codeBase = path.resolve(declaredCodeBase);
23
+
24
+ const ignored = [
25
+ // /css-loader/,
26
+ /tslib/,
27
+ /reflect-metadata/,
28
+ /\@microsoft\/fast-foundation\/.*/
29
+ ]
30
+
31
+ const enforced = [
32
+ /entities/,
33
+ /\@microsoft\/fast-foundation\/.*\/di/,
34
+ /\@microsoft\/fast-foundation\/.*\/foundation-element/
35
+ ]
36
+
37
+ const frontendDirs = [
38
+ codeBase,
39
+ __dirname
40
+ ];
41
+
42
+ const inFrontendContext = frontendDirs.some(dir => context.startsWith(dir)) ||
43
+ externalOptions._vars.frontendRequestContextCache.some(package => context.indexOf(package.request) > -1);
44
+
45
+ const patternInContextOrRequest = pattern => pattern.test(request) || pattern.test(context);
46
+
47
+ const isIgnored = ignored.some(patternInContextOrRequest);
48
+ const isEnforced = enforced.some(patternInContextOrRequest);
49
+
50
+ if (isEnforced || (!isIgnored && inFrontendContext)) {
51
+ if(!externalOptions._vars.packed.find(package => package.request === request && package.context === context)){
52
+ externalOptions._vars.packed.push({request, context});
53
+ }
54
+
55
+ externalOptions._vars.frontendRequestContextCache.push({request, context});
56
+
57
+ //merging to output
58
+ return callback();
59
+ }
60
+
61
+ externalOptions._vars.ignored.push({request, context});
62
+ //using require from node_modules
63
+ callback(null, false);
64
+ }
65
+
66
+ module.exports = {rwsExternals: externals, _externalsDefaults: _defaultOpts};
@@ -17,22 +17,19 @@ function setupTsConfig(tsConfigPath, executionDir) {
17
17
  let tsConfig = JSON.parse(tsConfigContents);
18
18
 
19
19
  const declarationsPath = path.resolve(__dirname, '..', 'types') + '/declarations.d.ts';
20
+ const foundationPath = path.resolve(__dirname, '..', 'foundation');
20
21
  const testsPath = path.resolve(__dirname, '..', 'tests');
21
22
  const declarationsPathMD5 = md5(fs.readFileSync(declarationsPath, 'utf-8'));
22
23
  const testsPathMD5 = fs.existsSync(testsPath) ? md5(fs.readFileSync(testsPath, 'utf-8')) : null;
23
24
 
24
25
  const relativeDeclarationsPath = path.relative(path.dirname(tsConfigPath), declarationsPath);
25
26
  const relativeTestsPath = path.relative(path.dirname(tsConfigPath), testsPath);
27
+ const relativeFoundationPath = path.relative(path.dirname(tsConfigPath), foundationPath);
26
28
 
27
- const includedMD5 = [];
28
29
 
29
- let changed = false;
30
+ const includedMD5 = [];
30
31
 
31
- if (!tsConfig['include'].includes('src')) {
32
- console.log(chalk.blueBright('[RWS TS CONFIG]'), 'adding RWS project typescript code to project tsconfig.json');
33
- tsConfig['include'].unshift('src');
34
- changed = true;
35
- }
32
+ let changed = false;
36
33
 
37
34
  if (!Object.keys(tsConfig).includes('include')) {
38
35
  tsConfig['include'] = [];
@@ -44,7 +41,14 @@ function setupTsConfig(tsConfigPath, executionDir) {
44
41
 
45
42
  return fs.existsSync(rwsPath.relativize(inc, executionDir))
46
43
  })
47
- }
44
+ }
45
+
46
+
47
+ if (!tsConfig['include'].includes('src')) {
48
+ console.log(chalk.blueBright('[RWS TS CONFIG]'), 'adding RWS project typescript code to project tsconfig.json');
49
+ tsConfig['include'].unshift('src');
50
+ changed = true;
51
+ }
48
52
 
49
53
  if (!Object.keys(tsConfig).includes('exclude')) {
50
54
  tsConfig['exclude'] = [];
@@ -73,6 +77,15 @@ function setupTsConfig(tsConfigPath, executionDir) {
73
77
  changed = true;
74
78
  }
75
79
 
80
+
81
+ // if(!Object.keys(tsConfig['compilerOptions']).includes('paths')){
82
+ // tsConfig['compilerOptions']['paths'] = {};
83
+ // changed = true;
84
+ // }
85
+
86
+ // if(!Object.keys(tsConfig['compilerOptions']['paths']).includes('@rws-framework/foundation')){
87
+ // tsConfig['compilerOptions']['paths']['@rws-framework/foundation'] = [relativeFoundationPath];
88
+ // }
76
89
 
77
90
 
78
91
  if (changed) {
@@ -82,8 +95,15 @@ function setupTsConfig(tsConfigPath, executionDir) {
82
95
 
83
96
  return true;
84
97
  } catch (e) {
85
- console.log(chalk.red('Error in tsconfig.json:'));
86
- console.log(chalk.blueBright(e.message));
98
+ const tsConfigFileContent = fs.readFileSync(tsConfigPath, 'utf-8');
99
+ try{
100
+ console.log(chalk.blueBright('TSConfig (parsed)'), JSON.parse(tsConfigFileContent));
101
+ } catch (e){
102
+ console.log(chalk.yellow('TSConfig (unparsed)'), tsConfigFileContent);
103
+
104
+ }
105
+ console.log(chalk.redBright('Error in tsconfig.json:'));
106
+ console.error(chalk.red(e.stack));
87
107
 
88
108
  return false;
89
109
  }
@@ -0,0 +1 @@
1
+ export * from './rws-foundation';
@@ -0,0 +1,8 @@
1
+ // fast-foundation.d.ts
2
+ import {DI, Container, Key, Registration , InterfaceSymbol} from '@microsoft/fast-foundation/dist/dts/di/di';
3
+ import { FoundationElement, FoundationElementDefinition, FoundationElementRegistry, OverrideFoundationElementDefinition } from '@microsoft/fast-foundation/dist/dts/foundation-element/foundation-element';
4
+
5
+ export {
6
+ DI, Container, Key, Registration , InterfaceSymbol,
7
+ FoundationElement, FoundationElementDefinition, FoundationElementRegistry, OverrideFoundationElementDefinition
8
+ }
@@ -0,0 +1,8 @@
1
+ // Extract only needed from fast-foundation
2
+ import {DI, Container, Registration} from '@microsoft/fast-foundation/dist/esm/di/di';
3
+ import { FoundationElement, FoundationElementRegistry } from '@microsoft/fast-foundation/dist/esm/foundation-element/foundation-element';
4
+
5
+ export {
6
+ DI, Container, Registration,
7
+ FoundationElement, FoundationElementRegistry
8
+ }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@rws-framework/client",
3
3
  "private": false,
4
- "version": "2.8.4",
5
- "main": "src/index.ts",
4
+ "version": "2.9.0",
5
+ "main": "src/index.ts",
6
6
  "scripts": {
7
7
  "docs": "typedoc --tsconfig ./tsconfig.json"
8
8
  },
@@ -31,6 +31,7 @@
31
31
  "@rws-framework/console": "*",
32
32
  "@types/moment": "^2.13.0",
33
33
  "dragula": "^3.7.3",
34
+ "deepmerge": "^4.3.1",
34
35
  "he": "^1.2.0",
35
36
  "json5": "^2.2.3",
36
37
  "lodash": "^4.17.21",
@@ -49,6 +50,7 @@
49
50
  "url-router": "^13.0.0",
50
51
  "uuid": "^9.0.1",
51
52
  "v4": "^0.0.1"
53
+
52
54
  },
53
55
  "devDependencies": {
54
56
  "@types/dragula": "^3.7.4",
@@ -73,8 +75,8 @@
73
75
  "source-map": "^0.7.4",
74
76
  "style-loader": "^3.3.3",
75
77
  "terser-webpack-plugin": "^5.3.9",
76
- "ts-loader": "^9.4.4",
77
- "html-loader": "^5.0.0",
78
+ "ts-loader": "^9.4.4",
79
+ "raw-loader": "^4.0.2",
78
80
  "ts-node": "^10.9.1",
79
81
  "tsconfig-paths": "^4.2.0",
80
82
  "tsconfig-paths-webpack-plugin": "^4.1.0",
@@ -1,19 +1,29 @@
1
1
  const path = require('path');
2
2
  const fs = require('fs');
3
3
  const webpack = require('webpack');
4
- const uglify = require('uglify-js')
4
+
5
+ const { rwsPath, RWSConfigBuilder } = require('@rws-framework/console');
6
+
5
7
  const HtmlWebpackPlugin = require('html-webpack-plugin');
6
8
  const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
7
- const chalk = require('chalk');
9
+ const TerserPlugin = require('terser-webpack-plugin');
10
+ const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
11
+
8
12
  const RWSAfterPlugin = require('./webpack/rws_after_plugin');
13
+
14
+ const chalk = require('chalk');
15
+
9
16
  const tools = require('./_tools');
17
+
18
+ const buildInfo = require('./cfg/build_steps/webpack/_info');
19
+ const { loadAliases } = require('./cfg/build_steps/webpack/_aliases');
20
+ const { getRWSLoaders } = require('./cfg/build_steps/webpack/_loaders');
21
+ const { rwsExternals } = require('./cfg/build_steps/webpack/_rws_externals');
22
+
10
23
  const { _DEFAULT_CONFIG } = require('./cfg/_default.cfg');
11
- const TerserPlugin = require('terser-webpack-plugin');
12
- const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
13
- const JsMinimizerPlugin = require('terser-webpack-plugin');
24
+ const { info } = require('console');
14
25
 
15
- const json5 = require('json5');
16
- const { rwsPath, RWSConfigBuilder } = require('@rws-framework/console');
26
+ const _MAIN_PACKAGE = rwsPath.findRootWorkspacePath(process.cwd());
17
27
 
18
28
  const RWSWebpackWrapper = async (config) => {
19
29
  const BuildConfigurator = new RWSConfigBuilder(rwsPath.findPackageDir(process.cwd()) + '/.rws.json', {..._DEFAULT_CONFIG, ...config});
@@ -40,7 +50,8 @@ const RWSWebpackWrapper = async (config) => {
40
50
 
41
51
  const publicIndex = BuildConfigurator.get('publicIndex') || config.publicIndex;
42
52
 
43
- const devTools = isDev ? (config.devtool || 'inline-source-map') : false;
53
+ const devTools = isDev ? (BuildConfigurator.get('devtool') || 'source-map') : false;
54
+ const devDebug = isDev ? (BuildConfigurator.get('devDebug') || config.devDebug || { build: false }) : null;
44
55
 
45
56
  const tsConfigPath = rwsPath.relativize(BuildConfigurator.get('tsConfigPath') || config.tsConfigPath, executionDir);
46
57
  const rwsPlugins = {};
@@ -54,19 +65,7 @@ const RWSWebpackWrapper = async (config) => {
54
65
 
55
66
  rwsPath.removeDirectory(outputDir, true);
56
67
 
57
- console.log(chalk.green('Build started with'))
58
- console.log({
59
- executionDir,
60
- tsConfigPath,
61
- outputDir,
62
- dev: isDev,
63
- publicDir,
64
- parted: isParted,
65
- partedPrefix,
66
- partedDirUrlPrefix,
67
- devtool: devTools
68
- });
69
-
68
+ buildInfo.start(executionDir, tsConfigPath, outputDir, isDev, publicDir, isParted, partedPrefix, partedDirUrlPrefix, devTools, config.rwsPlugins);
70
69
 
71
70
  //AFTER OPTION DEFINITIONS
72
71
 
@@ -75,14 +74,21 @@ const RWSWebpackWrapper = async (config) => {
75
74
  'process.env._RWS_DEFAULTS': JSON.stringify(BuildConfigurator.exportDefaultConfig()),
76
75
  'process.env._RWS_BUILD_OVERRIDE': JSON.stringify(BuildConfigurator.exportBuildConfig())
77
76
  }),
78
- new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en-gb/)
77
+ new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en-gb/),
78
+ new webpack.IgnorePlugin({
79
+ resourceRegExp: /.*\.es6\.js$/,
80
+ contextRegExp: /node_modules/
81
+ })
79
82
  ];
80
83
 
81
84
  const WEBPACK_AFTER_ACTIONS = config.actions || [];
85
+ const modules_setup = ['node_modules'];
86
+
87
+ let optimConfig = null;
88
+ let aliases = config.aliases = {};
89
+
90
+ aliases = {...aliases, ...loadAliases(__dirname, path.resolve(_MAIN_PACKAGE, 'node_modules'))}
82
91
 
83
- const aliases = config.aliases = {};
84
- aliases.fs = false;
85
- const modules_setup = [path.resolve(__dirname, 'node_modules'), 'node_modules'];
86
92
  const overridePlugins = config.plugins || []
87
93
 
88
94
  if (isHotReload) {
@@ -119,43 +125,36 @@ const RWSWebpackWrapper = async (config) => {
119
125
  type: 'copy',
120
126
  actionHandler: assetsToCopy
121
127
  });
122
- }
123
-
124
- if (WEBPACK_AFTER_ACTIONS.length) {
125
- WEBPACK_PLUGINS.push(new RWSAfterPlugin({ actions: WEBPACK_AFTER_ACTIONS }));
126
- }
128
+ }
127
129
 
128
130
  const rwsInfoJson = outputDir + '/rws_info.json'
129
131
  const automatedEntries = {};
132
+ const automatedChunks = {};
130
133
 
131
134
  const foundRWSUserClasses = tools.findComponentFilesWithText(executionDir, '@RWSView', ['dist', 'node_modules', '@rws-framework/client']);
132
135
  const foundRWSClientClasses = tools.findComponentFilesWithText(__dirname, '@RWSView', ['dist', 'node_modules']);
133
- let RWSComponents = [...foundRWSUserClasses, ...foundRWSClientClasses];
134
-
135
- const optimConfig = {};
136
+ let RWSComponents = [...foundRWSUserClasses, ...foundRWSClientClasses];
136
137
 
137
- if(!isDev){
138
- optimConfig.minimize = true;
139
- optimConfig.minimizer = [
140
- new TerserPlugin({
141
- terserOptions: {
142
- keep_classnames: true, // Prevent mangling of class names
143
- mangle: false, //@error breaks FAST view stuff if enabled for all assets
144
- compress: {
145
- dead_code: true,
146
- pure_funcs: ['console.log', 'console.info', 'console.warn']
147
- },
148
- output: {
149
- comments: false
150
- },
151
- },
152
- extractComments: false,
153
- parallel: true,
154
- }),
155
- new CssMinimizerPlugin(),
156
- ];
138
+ if (partedComponentsLocations) {
139
+ partedComponentsLocations.forEach((componentDir) => {
140
+ RWSComponents = [...RWSComponents, ...(tools.findComponentFilesWithText(path.resolve(componentDir), '@RWSView', ['dist', 'node_modules', '@rws-framework/client']))];
141
+ });
157
142
  }
158
-
143
+
144
+ RWSComponents.forEach((fileInfo) => {
145
+ const isIgnored = fileInfo.isIgnored;
146
+
147
+ if (isIgnored === true) {
148
+ // console.warn('Ignored: '+ fileInfo.filePath);
149
+ return;
150
+ }
151
+
152
+ automatedEntries[fileInfo.tagName] = fileInfo.filePath;
153
+
154
+ if(isParted){
155
+ automatedChunks[fileInfo.tagName] = fileInfo.filePath;
156
+ }
157
+ });
159
158
 
160
159
  if (isParted) {
161
160
  WEBPACK_PLUGINS.push(new webpack.BannerPlugin(tools.getPartedModeVendorsBannerParams(partedDirUrlPrefix, partedPrefix)));
@@ -163,28 +162,9 @@ const RWSWebpackWrapper = async (config) => {
163
162
  for (const pluginKey of Object.keys(rwsPlugins)){
164
163
  const plugin = rwsPlugins[pluginKey];
165
164
  partedComponentsLocations = await plugin.onComponentsLocated(partedComponentsLocations);
166
- }
167
-
168
- if (partedComponentsLocations) {
169
- partedComponentsLocations.forEach((componentDir) => {
170
- RWSComponents = [...RWSComponents, ...(tools.findComponentFilesWithText(path.resolve(componentDir), '@RWSView', ['dist', 'node_modules', '@rws-framework/client']))];
171
- });
172
165
  }
173
-
174
- RWSComponents.forEach((fileInfo) => {
175
- const isIgnored = fileInfo.isIgnored;
176
-
177
- if (isIgnored === true) {
178
- // console.warn('Ignored: '+ fileInfo.filePath);
179
- return;
180
- }
181
-
182
- automatedEntries[fileInfo.tagName] = fileInfo.filePath;
183
- });
184
-
185
- fs.writeFileSync(rwsInfoJson, JSON.stringify({ components: Object.keys(automatedEntries) }, null, 2));
186
-
187
- optimConfig.splitChunks = {
166
+
167
+ optimConfig = { splitChunks: {
188
168
  cacheGroups: {
189
169
  vendor: {
190
170
  test: (module) => {
@@ -209,24 +189,94 @@ const RWSWebpackWrapper = async (config) => {
209
189
  chunks: 'all',
210
190
  }
211
191
  }
212
- };
192
+ } };
213
193
  }
214
194
 
195
+ fs.writeFileSync(rwsInfoJson, JSON.stringify({ components: Object.keys(automatedEntries) }, null, 2));
196
+
215
197
  const tsValidated = tools.setupTsConfig(tsConfigPath, executionDir);
216
198
 
217
199
  if (!tsValidated) {
218
200
  throw new Error('RWS Webpack build failed.');
219
201
  }
220
202
 
203
+
204
+
205
+ if(!isDev){
206
+ if(!optimConfig){
207
+ optimConfig = {};
208
+ }
209
+
210
+ optimConfig = {
211
+ ...optimConfig,
212
+ minimize: true,
213
+ minimizer: [
214
+ new TerserPlugin({
215
+ terserOptions: {
216
+ keep_classnames: true, // Prevent mangling of class names
217
+ mangle: false, //@error breaks FAST view stuff if enabled for all assets
218
+ compress: !isDev ? {
219
+ dead_code: true,
220
+ pure_funcs: ['console.log', 'console.info', 'console.warn']
221
+ } : null,
222
+ output: {
223
+ comments: false,
224
+ beautify: isDev
225
+ },
226
+ },
227
+ extractComments: false,
228
+ parallel: true,
229
+ }),
230
+ new CssMinimizerPlugin({
231
+ minimizerOptions: {
232
+ preset: ['default', {
233
+ discardComments: { removeAll: false },
234
+ }],
235
+ },
236
+ })
237
+ ]
238
+ };
239
+ }
240
+
241
+ const devExternalsVars = {
242
+ packed: [],
243
+ ignored: [],
244
+ frontendRequestContextCache: []
245
+ }
246
+
247
+ if(devDebug?.build){
248
+ const debugDir = path.join(executionDir, '.debug');
249
+
250
+ if(!fs.existsSync(debugDir)){
251
+ fs.mkdirSync(debugDir)
252
+ }
253
+
254
+ WEBPACK_AFTER_ACTIONS.push({
255
+ type: 'custom',
256
+ actionHandler: () => {
257
+ fs.writeFileSync(path.join(debugDir, 'ignored.json'), JSON.stringify(devExternalsVars.ignored, null, 2));
258
+ fs.writeFileSync(path.join(debugDir, 'packed.json'), JSON.stringify(devExternalsVars.packed, null, 2));
259
+ fs.writeFileSync(path.join(debugDir, 'requestcache.json'), JSON.stringify(devExternalsVars.frontendRequestContextCache, null, 2));
260
+
261
+ console.log(chalk.yellow('[RWS BUILD] (after)'), `saved in: ${debugDir}/(ignored/packed/requestcache).json`);
262
+ }
263
+ });
264
+ }
265
+
266
+ if (WEBPACK_AFTER_ACTIONS.length) {
267
+ WEBPACK_PLUGINS.push(new RWSAfterPlugin({ actions: WEBPACK_AFTER_ACTIONS, dev: isDev }));
268
+ }
269
+
270
+
221
271
  let cfgExport = {
222
272
  context: executionDir,
223
273
  entry: {
224
274
  client: config.entry,
225
- ...automatedEntries
275
+ ...automatedChunks
226
276
  },
227
277
  mode: isDev ? 'development' : 'production',
228
278
  target: 'web',
229
- devtool: devTools,
279
+ devtool: devTools,
230
280
  output: {
231
281
  path: outputDir,
232
282
  filename: isParted ? (partedPrefix || 'rws') + '.[name].js' : outputFileName,
@@ -240,61 +290,17 @@ const RWSWebpackWrapper = async (config) => {
240
290
  }
241
291
  },
242
292
  module: {
243
- rules: [
244
- {
245
- test: /\.html$/,
246
- use: [
247
- {
248
- loader: 'html-loader'
249
- },
250
- path.resolve(__dirname, './webpack/loaders/rws_fast_html_loader.js')
251
- ],
252
- },
253
- {
254
- test: /\.css$/,
255
- use: [
256
- 'css-loader',
257
- ],
258
- },
259
- {
260
- test: /\.scss$/,
261
- use: [
262
- path.resolve(__dirname, './webpack/loaders/rws_fast_scss_loader.js'),
263
- ],
264
- },
265
- {
266
- test: /\.(ts)$/,
267
- use: [
268
- {
269
- loader: 'ts-loader',
270
- options: {
271
- allowTsInNodeModules: true,
272
- configFile: path.resolve(tsConfigPath)
273
- }
274
- },
275
- {
276
- loader: path.resolve(__dirname, './webpack/loaders/rws_fast_ts_loader.js'),
277
- }
278
- ],
279
- exclude: [
280
- /node_modules\/(?!\@rws-framework\/client)/,
281
- /\.debug\.ts$/,
282
- ],
283
- }
284
- ],
293
+ rules: getRWSLoaders(__dirname, path.resolve(config.packageDir, 'node_modules'), tsConfigPath),
285
294
  },
286
- plugins: WEBPACK_PLUGINS,
287
- optimization: optimConfig,
295
+ plugins: WEBPACK_PLUGINS,
296
+ externals: rwsExternals(executionDir, modules_setup, {
297
+ _vars: devExternalsVars
298
+ })
288
299
  }
289
300
 
290
- // if(isDev){
291
- cfgExport.module.rules.push({
292
- test: /\.js$/,
293
- use: [
294
- path.resolve(__dirname, './webpack/loaders/rws_uncomments_loader.js'),
295
- ],
296
- })
297
- // }
301
+ if(optimConfig){
302
+ cfgExport.optimization = optimConfig;
303
+ }
298
304
 
299
305
  if (isHotReload) {
300
306
  cfgExport.devServer = {
@@ -306,7 +312,7 @@ const RWSWebpackWrapper = async (config) => {
306
312
  for (const pluginKey of Object.keys(rwsPlugins)){
307
313
  const plugin = rwsPlugins[pluginKey];
308
314
  cfgExport = await plugin.onBuild(cfgExport);
309
- }
315
+ }
310
316
 
311
317
  return cfgExport;
312
318
  }
@@ -2,7 +2,7 @@ import IRWSUser from '../../src/types/IRWSUser';
2
2
  import RWSContainer from '../../src/components/_container';
3
3
 
4
4
  //@4DI
5
- import { Container } from '@microsoft/fast-foundation';
5
+ import { Container } from '../../src/components/_container';
6
6
 
7
7
  type SWMsgType = {
8
8
  command: string,