@rws-framework/client 2.8.5 → 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.
- package/cfg/build_steps/webpack/_aliases.js +10 -0
- package/cfg/build_steps/webpack/_info.js +19 -0
- package/cfg/build_steps/webpack/_loaders.js +40 -0
- package/cfg/build_steps/webpack/_rws_externals.js +66 -0
- package/cfg/tsconfigSetup.js +30 -10
- package/foundation/index.js +1 -0
- package/foundation/rws-foundation.d.ts +8 -0
- package/foundation/rws-foundation.js +8 -0
- package/package.json +5 -4
- package/rws.webpack.config.js +139 -145
- package/service_worker/src/_service_worker.ts +1 -1
- package/src/client/config.ts +10 -3
- package/src/client.ts +2 -2
- package/src/components/_attrs/external-observable.ts +72 -0
- package/src/components/_component.ts +4 -5
- package/src/components/_container.ts +4 -4
- package/src/components/_decorator.ts +39 -9
- package/src/components/_decorators/RWSFillBuild.ts +0 -1
- package/src/components/_decorators/RWSInject.ts +3 -3
- package/src/components/_decorators/_di.ts +2 -2
- package/src/index.d.ts +1 -0
- package/src/index.ts +5 -5
- package/src/plugins/_plugin.ts +1 -1
- package/src/services/ConfigService.ts +3 -1
- package/src/services/_service.ts +10 -7
- package/src/types/RWSWindow.ts +2 -1
- package/tsconfig.json +5 -1
- package/webpack/loaders/rws_fast_scss_loader.js +20 -3
- package/webpack/loaders/rws_fast_ts_loader.js +3 -2
- package/webpack/rws_after_plugin.js +26 -23
- package/webpack/rws_scss_plugin.js +7 -8
- package/_rws_externals.js +0 -39
- package/src/components/_design_system.ts +0 -6
- package/webpack/loaders/rws_fast_html_loader.js +0 -8
- package/webpack/loaders/rws_uncomments_loader.js +0 -35
|
@@ -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};
|
package/cfg/tsconfigSetup.js
CHANGED
|
@@ -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
|
-
|
|
30
|
+
const includedMD5 = [];
|
|
30
31
|
|
|
31
|
-
|
|
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
|
-
|
|
86
|
-
|
|
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.
|
|
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",
|
|
@@ -74,8 +75,8 @@
|
|
|
74
75
|
"source-map": "^0.7.4",
|
|
75
76
|
"style-loader": "^3.3.3",
|
|
76
77
|
"terser-webpack-plugin": "^5.3.9",
|
|
77
|
-
"ts-loader": "^9.4.4",
|
|
78
|
-
"
|
|
78
|
+
"ts-loader": "^9.4.4",
|
|
79
|
+
"raw-loader": "^4.0.2",
|
|
79
80
|
"ts-node": "^10.9.1",
|
|
80
81
|
"tsconfig-paths": "^4.2.0",
|
|
81
82
|
"tsconfig-paths-webpack-plugin": "^4.1.0",
|
package/rws.webpack.config.js
CHANGED
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const webpack = require('webpack');
|
|
4
|
-
|
|
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
|
|
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
|
|
12
|
-
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
13
|
-
const JsMinimizerPlugin = require('terser-webpack-plugin');
|
|
24
|
+
const { info } = require('console');
|
|
14
25
|
|
|
15
|
-
const
|
|
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 ? (
|
|
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
|
-
|
|
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,84 +125,46 @@ 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
|
-
|
|
137
|
-
// if(!isDev){
|
|
138
|
-
optimConfig.minimize = !isDev;
|
|
139
|
-
optimConfig.minimizer = !isDev ? [
|
|
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: !isDev ? {
|
|
145
|
-
dead_code: true,
|
|
146
|
-
pure_funcs: ['console.log', 'console.info', 'console.warn']
|
|
147
|
-
} : null,
|
|
148
|
-
output: {
|
|
149
|
-
comments: false
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
extractComments: false,
|
|
153
|
-
parallel: true,
|
|
154
|
-
}),
|
|
155
|
-
new CssMinimizerPlugin()
|
|
156
|
-
] : [
|
|
157
|
-
new TerserPlugin({
|
|
158
|
-
terserOptions: {
|
|
159
|
-
keep_classnames: true, // Prevent mangling of class names
|
|
160
|
-
mangle: false, //@error breaks FAST view stuff if enabled for all assets
|
|
161
|
-
output: {
|
|
162
|
-
comments: false
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
extractComments: false,
|
|
166
|
-
parallel: false,
|
|
167
|
-
})
|
|
168
|
-
]
|
|
169
|
-
// }
|
|
170
|
-
|
|
136
|
+
let RWSComponents = [...foundRWSUserClasses, ...foundRWSClientClasses];
|
|
171
137
|
|
|
172
|
-
if (
|
|
173
|
-
|
|
138
|
+
if (partedComponentsLocations) {
|
|
139
|
+
partedComponentsLocations.forEach((componentDir) => {
|
|
140
|
+
RWSComponents = [...RWSComponents, ...(tools.findComponentFilesWithText(path.resolve(componentDir), '@RWSView', ['dist', 'node_modules', '@rws-framework/client']))];
|
|
141
|
+
});
|
|
142
|
+
}
|
|
174
143
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
partedComponentsLocations = await plugin.onComponentsLocated(partedComponentsLocations);
|
|
178
|
-
}
|
|
144
|
+
RWSComponents.forEach((fileInfo) => {
|
|
145
|
+
const isIgnored = fileInfo.isIgnored;
|
|
179
146
|
|
|
180
|
-
if (
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
});
|
|
147
|
+
if (isIgnored === true) {
|
|
148
|
+
// console.warn('Ignored: '+ fileInfo.filePath);
|
|
149
|
+
return;
|
|
184
150
|
}
|
|
185
|
-
|
|
186
|
-
RWSComponents.forEach((fileInfo) => {
|
|
187
|
-
const isIgnored = fileInfo.isIgnored;
|
|
188
151
|
|
|
189
|
-
|
|
190
|
-
// console.warn('Ignored: '+ fileInfo.filePath);
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
152
|
+
automatedEntries[fileInfo.tagName] = fileInfo.filePath;
|
|
193
153
|
|
|
194
|
-
|
|
195
|
-
|
|
154
|
+
if(isParted){
|
|
155
|
+
automatedChunks[fileInfo.tagName] = fileInfo.filePath;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
196
158
|
|
|
197
|
-
|
|
159
|
+
if (isParted) {
|
|
160
|
+
WEBPACK_PLUGINS.push(new webpack.BannerPlugin(tools.getPartedModeVendorsBannerParams(partedDirUrlPrefix, partedPrefix)));
|
|
198
161
|
|
|
199
|
-
|
|
162
|
+
for (const pluginKey of Object.keys(rwsPlugins)){
|
|
163
|
+
const plugin = rwsPlugins[pluginKey];
|
|
164
|
+
partedComponentsLocations = await plugin.onComponentsLocated(partedComponentsLocations);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
optimConfig = { splitChunks: {
|
|
200
168
|
cacheGroups: {
|
|
201
169
|
vendor: {
|
|
202
170
|
test: (module) => {
|
|
@@ -221,24 +189,94 @@ const RWSWebpackWrapper = async (config) => {
|
|
|
221
189
|
chunks: 'all',
|
|
222
190
|
}
|
|
223
191
|
}
|
|
224
|
-
};
|
|
192
|
+
} };
|
|
225
193
|
}
|
|
226
194
|
|
|
195
|
+
fs.writeFileSync(rwsInfoJson, JSON.stringify({ components: Object.keys(automatedEntries) }, null, 2));
|
|
196
|
+
|
|
227
197
|
const tsValidated = tools.setupTsConfig(tsConfigPath, executionDir);
|
|
228
198
|
|
|
229
199
|
if (!tsValidated) {
|
|
230
200
|
throw new Error('RWS Webpack build failed.');
|
|
231
201
|
}
|
|
232
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
|
+
|
|
233
271
|
let cfgExport = {
|
|
234
272
|
context: executionDir,
|
|
235
273
|
entry: {
|
|
236
274
|
client: config.entry,
|
|
237
|
-
...
|
|
275
|
+
...automatedChunks
|
|
238
276
|
},
|
|
239
277
|
mode: isDev ? 'development' : 'production',
|
|
240
278
|
target: 'web',
|
|
241
|
-
devtool: devTools,
|
|
279
|
+
devtool: devTools,
|
|
242
280
|
output: {
|
|
243
281
|
path: outputDir,
|
|
244
282
|
filename: isParted ? (partedPrefix || 'rws') + '.[name].js' : outputFileName,
|
|
@@ -252,61 +290,17 @@ const RWSWebpackWrapper = async (config) => {
|
|
|
252
290
|
}
|
|
253
291
|
},
|
|
254
292
|
module: {
|
|
255
|
-
rules:
|
|
256
|
-
{
|
|
257
|
-
test: /\.html$/,
|
|
258
|
-
use: [
|
|
259
|
-
{
|
|
260
|
-
loader: 'html-loader'
|
|
261
|
-
},
|
|
262
|
-
path.resolve(__dirname, './webpack/loaders/rws_fast_html_loader.js')
|
|
263
|
-
],
|
|
264
|
-
},
|
|
265
|
-
{
|
|
266
|
-
test: /\.css$/,
|
|
267
|
-
use: [
|
|
268
|
-
'css-loader',
|
|
269
|
-
],
|
|
270
|
-
},
|
|
271
|
-
{
|
|
272
|
-
test: /\.scss$/,
|
|
273
|
-
use: [
|
|
274
|
-
path.resolve(__dirname, './webpack/loaders/rws_fast_scss_loader.js'),
|
|
275
|
-
],
|
|
276
|
-
},
|
|
277
|
-
{
|
|
278
|
-
test: /\.(ts)$/,
|
|
279
|
-
use: [
|
|
280
|
-
{
|
|
281
|
-
loader: 'ts-loader',
|
|
282
|
-
options: {
|
|
283
|
-
allowTsInNodeModules: true,
|
|
284
|
-
configFile: path.resolve(tsConfigPath)
|
|
285
|
-
}
|
|
286
|
-
},
|
|
287
|
-
{
|
|
288
|
-
loader: path.resolve(__dirname, './webpack/loaders/rws_fast_ts_loader.js'),
|
|
289
|
-
}
|
|
290
|
-
],
|
|
291
|
-
exclude: [
|
|
292
|
-
/node_modules\/(?!\@rws-framework\/[A-Z0-9a-z])/,
|
|
293
|
-
/\.debug\.ts$/,
|
|
294
|
-
],
|
|
295
|
-
}
|
|
296
|
-
],
|
|
293
|
+
rules: getRWSLoaders(__dirname, path.resolve(config.packageDir, 'node_modules'), tsConfigPath),
|
|
297
294
|
},
|
|
298
|
-
plugins: WEBPACK_PLUGINS,
|
|
299
|
-
|
|
295
|
+
plugins: WEBPACK_PLUGINS,
|
|
296
|
+
externals: rwsExternals(executionDir, modules_setup, {
|
|
297
|
+
_vars: devExternalsVars
|
|
298
|
+
})
|
|
300
299
|
}
|
|
301
300
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
// use: [
|
|
306
|
-
// path.resolve(__dirname, './webpack/loaders/rws_uncomments_loader.js'),
|
|
307
|
-
// ],
|
|
308
|
-
// })
|
|
309
|
-
// }
|
|
301
|
+
if(optimConfig){
|
|
302
|
+
cfgExport.optimization = optimConfig;
|
|
303
|
+
}
|
|
310
304
|
|
|
311
305
|
if (isHotReload) {
|
|
312
306
|
cfgExport.devServer = {
|
|
@@ -318,7 +312,7 @@ const RWSWebpackWrapper = async (config) => {
|
|
|
318
312
|
for (const pluginKey of Object.keys(rwsPlugins)){
|
|
319
313
|
const plugin = rwsPlugins[pluginKey];
|
|
320
314
|
cfgExport = await plugin.onBuild(cfgExport);
|
|
321
|
-
}
|
|
315
|
+
}
|
|
322
316
|
|
|
323
317
|
return cfgExport;
|
|
324
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 '
|
|
5
|
+
import { Container } from '../../src/components/_container';
|
|
6
6
|
|
|
7
7
|
type SWMsgType = {
|
|
8
8
|
command: string,
|