@rws-framework/client 2.10.9 → 2.10.10

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.
@@ -71,9 +71,9 @@ function devActions(WEBPACK_AFTER_ACTIONS, executionDir, devDebug){
71
71
  WEBPACK_AFTER_ACTIONS.push({
72
72
  type: 'custom',
73
73
  actionHandler: () => {
74
- fs.writeFileSync(path.join(debugDir, 'in_vendors.json'), JSON.stringify(devExternalsVars.ignored, null, 2));
75
- fs.writeFileSync(path.join(debugDir, 'rws_processed.json'), JSON.stringify(devExternalsVars.packed, null, 2));
76
- fs.writeFileSync(path.join(debugDir, 'requestcache.json'), JSON.stringify(devExternalsVars.frontendRequestContextCache, null, 2));
74
+ fs.writeFile(path.join(debugDir, 'in_vendors.json'), JSON.stringify(devExternalsVars.ignored, null, 2));
75
+ fs.writeFile(path.join(debugDir, 'rws_processed.json'), JSON.stringify(devExternalsVars.packed, null, 2));
76
+ fs.writeFile(path.join(debugDir, 'requestcache.json'), JSON.stringify(devExternalsVars.frontendRequestContextCache, null, 2));
77
77
 
78
78
  console.log(chalk.yellow('[RWS BUILD] (after)'), `packaging debug saved in: ${debugDir}`);
79
79
  }
@@ -1,13 +1,8 @@
1
1
  const path = require('path');
2
2
 
3
- function loadAliases(packageDir, nodeModulesPath){
3
+ function loadAliases(packageDir, nodeModulesPath, srcDir){
4
4
  return {
5
- fs: false,
6
- path: false,
7
- http: false,
8
- https: false,
9
- os: false,
10
- stream: false,
5
+ 'src': srcDir + '/src',
11
6
  '@rws-framework/foundation': path.resolve(packageDir, 'foundation', 'rws-foundation.js')
12
7
  }
13
8
  }
@@ -30,7 +30,7 @@ async function getBuildConfig(rwsFrontBuildConfig){
30
30
 
31
31
  const devTools = isDev ? (BuildConfigurator.get('devtool') || 'source-map') : false;
32
32
 
33
- const _DEFAULT_DEV_DEBUG = { build: false, timing: false, rwsCache: false };
33
+ const _DEFAULT_DEV_DEBUG = { build: false, timing: false, rwsCache: false, profiling: false };
34
34
 
35
35
  let devDebug = isDev ? (BuildConfigurator.get('devDebug') || rwsFrontBuildConfig.devDebug || {}) : {};
36
36
  devDebug = {..._DEFAULT_DEV_DEBUG, ...devDebug}
@@ -42,7 +42,7 @@ function setComponentsChunks(clientEntry, RWSComponents = [], isParted = false)
42
42
 
43
43
  function generateRWSInfoFile(outputDir, automatedEntries) {
44
44
  const rwsInfoJson = outputDir + '/rws_info.json'
45
- fs.writeFileSync(rwsInfoJson, JSON.stringify({ components: Object.keys(automatedEntries) }, null, 2));
45
+ fs.writeFile(rwsInfoJson, JSON.stringify({ components: Object.keys(automatedEntries) }, null, 2), () => {});
46
46
  }
47
47
 
48
48
  async function partedComponentsEvents(partedComponentsLocations, rwsPlugins, isParted) {
@@ -1,5 +1,7 @@
1
1
  const path = require('path');
2
2
  const fs = require('fs');
3
+ const os = require('os');
4
+
3
5
  const RWSCssPlugin = require("../../../webpack/rws_scss_plugin");
4
6
  const plugin = new RWSCssPlugin();
5
7
  const JSON5 = require('json5');
@@ -12,6 +14,7 @@ function getRWSLoaders(packageDir, nodeModulesPath, tsConfigPath, devDebug) {
12
14
  const tsLoader = packageDir + '/webpack/loaders/rws_fast_ts_loader.js';
13
15
  const htmlLoader = packageDir + '/webpack/loaders/rws_fast_html_loader.js';
14
16
 
17
+
15
18
  return [
16
19
  {
17
20
  test: /\.html$/,
@@ -27,6 +30,7 @@ function getRWSLoaders(packageDir, nodeModulesPath, tsConfigPath, devDebug) {
27
30
  {
28
31
  loader: 'ts-loader',
29
32
  options: {
33
+ transpileOnly: true,
30
34
  allowTsInNodeModules: true,
31
35
  configFile: path.resolve(tsConfigPath)
32
36
  }
@@ -35,7 +39,7 @@ function getRWSLoaders(packageDir, nodeModulesPath, tsConfigPath, devDebug) {
35
39
  loader: tsLoader,
36
40
  }
37
41
  ],
38
- exclude: [
42
+ exclude: [
39
43
  /node_modules\/(?!\@rws-framework\/[A-Z0-9a-z])/,
40
44
  /\.debug\.ts$/,
41
45
  /\.d\.ts$/,
@@ -3,6 +3,7 @@ const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
3
3
  const HtmlWebpackPlugin = require('html-webpack-plugin');
4
4
  const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
5
5
  const { processEnvDefines } = require('./_env_defines');
6
+ const path = require('path');
6
7
 
7
8
  const RWS_WEBPACK_PLUGINS_BAG = {
8
9
  _plugins: [],
@@ -48,22 +49,24 @@ function getDefinesPlugins(BuildConfigurator, rwsFrontendConfig, devDebug) {
48
49
  ]
49
50
  }
50
51
 
51
- function getBuilderOptimPlugins(BuildConfigurator, rwsFrontendConfig, tsConfigPath) {
52
- const tsFork = new ForkTsCheckerWebpackPlugin({
53
- async: false,
54
- typescript: {
55
- configFile: tsConfigPath,
56
- diagnosticOptions: {
57
- semantic: true,
58
- syntactic: true,
59
- },
60
- },
61
- });
52
+ function getBuilderDevPlugins(BuildConfigurator, rwsFrontendConfig, tsConfigPath, devDebug) {
53
+ if(!devDebug?.profiling){
54
+ return [];
55
+ }
62
56
 
57
+ const profiling = new webpack.debug.ProfilingPlugin({
58
+ outputPath: path.join(BuildConfigurator.get('outputDir') || rwsFrontendConfig.outputDir, '.profiling/profileEvents.json'),
59
+ });
63
60
 
64
61
 
65
62
  return [
66
-
63
+ profiling
64
+ ]
65
+ }
66
+
67
+ function getBuilderOptimPlugins(BuildConfigurator, rwsFrontendConfig, tsConfigPath) {
68
+ return [
69
+
67
70
  ]
68
71
  }
69
72
 
@@ -71,6 +74,7 @@ function addStartPlugins(rwsFrontendConfig, BuildConfigurator, devDebug, isHotRe
71
74
 
72
75
  RWS_WEBPACK_PLUGINS_BAG.add([
73
76
  ...getDefinesPlugins(BuildConfigurator, rwsFrontendConfig, devDebug),
77
+ ...getBuilderDevPlugins(BuildConfigurator, rwsFrontendConfig, tsConfigPath, devDebug),
74
78
  ...getBuilderOptimPlugins(BuildConfigurator, rwsFrontendConfig, tsConfigPath),
75
79
  ...getPackageModPlugins()
76
80
  ]);
@@ -5,7 +5,7 @@ const { rwsPath } = require('@rws-framework/console');
5
5
  const path = require('path');
6
6
  const fs = require('fs');
7
7
 
8
- function setupTsConfig(tsConfigPath, executionDir) {
8
+ function setupTsConfig(tsConfigPath, executionDir, userAliases = {}) {
9
9
 
10
10
  if (!fs.existsSync(tsConfigPath)) {
11
11
  throw new Error(`Typescript config file "${tsConfigPath}" does not exist`);
@@ -27,36 +27,37 @@ function setupTsConfig(tsConfigPath, executionDir) {
27
27
 
28
28
 
29
29
  const includedMD5 = [];
30
+ const srcPath = 'src/index.ts';
30
31
 
31
- let changed = false;
32
+ let changed = false;
32
33
 
33
34
  if (!Object.keys(tsConfig).includes('include')) {
34
35
  tsConfig['include'] = [];
35
36
  } else {
36
37
  tsConfig['include'] = tsConfig['include'].filter((inc) => {
37
- if(inc === 'src/index.ts'){
38
+ if (inc === srcPath) {
38
39
  return true;
39
- }
40
+ }
40
41
 
41
- return fs.existsSync(rwsPath.relativize(inc, executionDir))
42
+ return fs.existsSync(rwsPath.relativize(inc, executionDir));
42
43
  })
43
- }
44
-
45
-
46
- if (!tsConfig['include'].includes('src/index.ts')) {
44
+ }
45
+
46
+
47
+ if (!tsConfig['include'].includes(srcPath)) {
47
48
  console.log(chalk.blueBright('[RWS TS CONFIG]'), 'adding RWS project typescript code to project tsconfig.json');
48
- tsConfig['include'].unshift('src/index.ts');
49
+ tsConfig['include'].unshift(srcPath);
49
50
  changed = true;
50
- }
51
+ }
51
52
 
52
53
  if (!Object.keys(tsConfig).includes('exclude')) {
53
- tsConfig['exclude'] = [];
54
+ tsConfig['exclude'] = [];
54
55
  changed = true;
55
- }
56
-
56
+ }
57
+
57
58
  const excludeString = '**/*.debug.ts';
58
59
 
59
- if(!tsConfig['exclude'].includes(excludeString)){
60
+ if (!tsConfig['exclude'].includes(excludeString)) {
60
61
  tsConfig['exclude'].push(excludeString);
61
62
  changed = true;
62
63
  }
@@ -64,28 +65,49 @@ function setupTsConfig(tsConfigPath, executionDir) {
64
65
  let probablyLinked = false;
65
66
 
66
67
  tsConfig['include'].forEach(element => {
67
- if(element !== 'src' && element.indexOf('declarations.d.ts') > -1 && md5(fs.readFileSync(rwsPath.relativize(element, executionDir), 'utf-8')) === md5(fs.readFileSync(declarationsPath, 'utf-8'))){
68
+ if (element !== 'src' && element.indexOf('declarations.d.ts') > -1 && md5(fs.readFileSync(rwsPath.relativize(element, executionDir), 'utf-8')) === md5(fs.readFileSync(declarationsPath, 'utf-8'))) {
68
69
  probablyLinked = true;
69
- }
70
- });
70
+ }
71
+ });
71
72
 
72
73
  if (!tsConfig['include'].includes(relativeDeclarationsPath) && !probablyLinked) {
73
74
  console.log(chalk.blueBright('[RWS TS CONFIG]'), 'adding RWS typescript declarations to project tsconfig.json');
74
75
  tsConfig['include'].push(relativeDeclarationsPath);
75
76
  includedMD5.push(md5(fs.readFileSync(declarationsPath, 'utf-8')));
76
77
  changed = true;
77
- }
78
+ }
78
79
 
80
+ if(!tsConfig.compilerOptions){
81
+ throw new Error(`${tsConfigPath} needs "compilerOptions" section`)
82
+ }
83
+
84
+ if (Object.keys(userAliases).length) {
85
+ const tsPaths = tsConfig.compilerOptions?.paths || {};
86
+
87
+ // console.log({tsPaths})
88
+ let changedPaths = false;
89
+
90
+ Object.keys(userAliases).forEach((alias) => {
91
+ const aliasPath = userAliases[alias];
92
+ if(!tsPaths[alias]){
93
+
94
+ tsPaths[alias] = [path.relative(executionDir, aliasPath)];
79
95
 
80
- // if(!Object.keys(tsConfig['compilerOptions']).includes('paths')){
81
- // tsConfig['compilerOptions']['paths'] = {};
82
- // changed = true;
83
- // }
96
+ console.log({alias, x: tsPaths[alias]});
97
+
98
+ changedPaths = true;
99
+ }
100
+ });
101
+
102
+ if(changedPaths){
103
+ console.log('tspaths', tsPaths);
104
+ console.log(chalk.blueBright('[RWS TS CONFIG]'), 'adding user aliases as paths to project tsconfig.json');
105
+
106
+ tsConfig.compilerOptions.paths = tsPaths;
107
+ changed = true;
108
+ }
109
+ }
84
110
 
85
- // if(!Object.keys(tsConfig['compilerOptions']['paths']).includes('@rws-framework/foundation')){
86
- // tsConfig['compilerOptions']['paths']['@rws-framework/foundation'] = [relativeFoundationPath];
87
- // }
88
-
89
111
 
90
112
  if (changed) {
91
113
  fs.writeFileSync(tsConfigPath, JSON.stringify(tsConfig, null, 2));
@@ -95,13 +117,13 @@ function setupTsConfig(tsConfigPath, executionDir) {
95
117
  return true;
96
118
  } catch (e) {
97
119
  const tsConfigFileContent = fs.readFileSync(tsConfigPath, 'utf-8');
98
- try{
120
+ try {
99
121
  console.log(chalk.blueBright('TSConfig (parsed)'), JSON.parse(tsConfigFileContent));
100
- } catch (e){
122
+ } catch (e) {
101
123
  console.log(chalk.yellow('TSConfig (unparsed)'), tsConfigFileContent);
102
124
 
103
125
  }
104
- console.log(chalk.redBright('Error in tsconfig.json:'));
126
+ console.log(chalk.redBright('Error in tsconfig.json:'));
105
127
  console.error(chalk.red(e.stack));
106
128
 
107
129
  return false;
package/console.js CHANGED
@@ -56,18 +56,18 @@ async function initCmd(){
56
56
  if(workspaced){
57
57
  if(!fs.existsSync(`${executionDir}/.eslintrc.json`)){
58
58
  const rcjs = fs.readFileSync(`${moduleDir}/.setup/.eslintrc.json`, 'utf-8');
59
- fs.writeFileSync(`${executionDir}/.eslintrc.json`, rcjs.replace('{{frontend_dir}}', executionDir));
59
+ fs.writeFile(`${executionDir}/.eslintrc.json`, rcjs.replace('{{frontend_dir}}', executionDir));
60
60
  console.log(chalk.green('RWS CLI'), 'Installed eslint base workspace config file.');
61
61
  }
62
62
  }else{
63
63
  if(!fs.existsSync(`${executionDir}/.eslintrc.json`)){
64
- fs.copyFileSync(`${moduleDir}/.eslintrc.json`, `${executionDir}/.eslintrc.json`);
64
+ fs.copyFile(`${moduleDir}/.eslintrc.json`, `${executionDir}/.eslintrc.json`);
65
65
  console.log(chalk.green('[RWS Client]'), 'Installed eslint config file.');
66
66
  }
67
67
  }
68
68
 
69
69
  if(!fs.existsSync(`${executionDir}/tsconfig.json`)){
70
- fs.copyFileSync(`${moduleDir}/.setup/tsconfig.json`, `${executionDir}/tsconfig.json`);
70
+ fs.copyFile(`${moduleDir}/.setup/tsconfig.json`, `${executionDir}/tsconfig.json`);
71
71
  console.log(chalk.green('[RWS Client]'), 'Installed tsconfig.');
72
72
  }
73
73
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rws-framework/client",
3
3
  "private": false,
4
- "version": "2.10.9",
4
+ "version": "2.10.10",
5
5
  "main": "src/index.ts",
6
6
  "scripts": {
7
7
  "docs": "typedoc --tsconfig ./tsconfig.json"
@@ -61,14 +61,14 @@
61
61
  "@types/he": "^1.2.3",
62
62
  "@types/sanitize-html": "^2.11.0",
63
63
  "@types/uuid": "^9.0.7",
64
- "@typescript-eslint/parser": "^5.0.0",
65
- "fork-ts-checker-webpack-plugin": "^9.0.2",
64
+ "@typescript-eslint/parser": "^5.0.0",
66
65
  "browser-sync": "^2.29.3",
67
66
  "clean-webpack-plugin": "^4.0.0",
68
67
  "css-loader": "^6.8.1",
69
68
  "css-minimizer-webpack-plugin": "^5.0.1",
70
69
  "eslint": "^6.0.0",
71
70
  "file-loader": "^6.2.0",
71
+ "fork-ts-checker-webpack-plugin": "^9.0.2",
72
72
  "html-webpack-plugin": "^5.5.3",
73
73
  "loader-utils": "^3.2.1",
74
74
  "mini-css-extract-plugin": "^2.7.6",
@@ -77,6 +77,7 @@
77
77
  "raw-loader": "^4.0.2",
78
78
  "sass-loader": "^13.3.2",
79
79
  "source-map": "^0.7.4",
80
+ "speed-measure-webpack-plugin": "^1.5.0",
80
81
  "style-loader": "^3.3.3",
81
82
  "terser-webpack-plugin": "^5.3.9",
82
83
  "ts-loader": "^9.4.4",
@@ -52,10 +52,9 @@ const RWSWebpackWrapper = async (rwsFrontendConfig) => {
52
52
 
53
53
  if (devDebug?.timing) {
54
54
  timingStart('build config');
55
- }
56
-
57
- //rwsPath.removeDirectory(outputDir, true);
55
+ }
58
56
 
57
+ rwsPath.removeDirectory(outputDir, true);
59
58
  buildInfo.start(executionDir, tsConfigPath, outputDir, isDev, publicDir, isParted, partedPrefix, partedDirUrlPrefix, devTools, rwsFrontendConfig.rwsPlugins);
60
59
 
61
60
  // #SECTION INIT PLUGINS && ENV VARS DEFINES
@@ -67,9 +66,9 @@ const RWSWebpackWrapper = async (rwsFrontendConfig) => {
67
66
  const modules_setup = ['node_modules'];
68
67
 
69
68
  let optimConfig = null;
70
- let aliases = rwsFrontendConfig.aliases = {};
69
+ let aliases = rwsFrontendConfig.aliases || {};
71
70
 
72
- aliases = { ...aliases, ...loadAliases(__dirname, path.resolve(_MAIN_PACKAGE, 'node_modules')) }
71
+ aliases = { ...aliases, ...loadAliases(__dirname, path.resolve(_MAIN_PACKAGE, 'node_modules'), executionDir) }
73
72
 
74
73
  // #SECTION PLUGIN STARTING HOOKS
75
74
 
@@ -91,7 +90,7 @@ const RWSWebpackWrapper = async (rwsFrontendConfig) => {
91
90
 
92
91
 
93
92
  // #SECTION TSCONFIG VALIDATION/SETUP
94
- const tsValidated = tools.setupTsConfig(tsConfigPath, executionDir);
93
+ const tsValidated = tools.setupTsConfig(tsConfigPath, executionDir, rwsFrontendConfig.aliases);
95
94
 
96
95
  if (!tsValidated) {
97
96
  throw new Error('RWS Webpack build failed.');
@@ -156,7 +155,7 @@ const RWSWebpackWrapper = async (rwsFrontendConfig) => {
156
155
  if (isDev) {
157
156
  // #SECTION RWS DEV SERVERS
158
157
  webpackDevServer(BuildConfigurator, rwsFrontendConfig, cfgExport);
159
- }
158
+ }
160
159
 
161
160
  return cfgExport;
162
161
  }
@@ -7,7 +7,11 @@ module.exports = function(content){
7
7
  const componentPath = path.resolve(componentDir, 'component.ts');
8
8
 
9
9
  if(fs.existsSync(componentPath)){
10
- fs.writeFileSync(componentPath, fs.readFileSync(componentPath, 'utf-8'))
10
+ const fileCnt = fs.readFileSync(componentPath, 'utf-8');
11
+
12
+ if(fileCnt){
13
+ fs.writeFile(componentPath, fileCnt, () => {})
14
+ }
11
15
  }
12
16
 
13
17
  return '';
@@ -1,7 +1,6 @@
1
1
  const path = require('path');
2
2
  const fs = require('fs');
3
3
  const RWSScssPlugin = require('../rws_scss_plugin');
4
- const { timingStart, timingStop } = require('../../cfg/build_steps/webpack/_timing');
5
4
 
6
5
  module.exports = async function(content) {
7
6
  const filePath = this.resourcePath;
@@ -13,10 +12,8 @@ module.exports = async function(content) {
13
12
  let fromTs = false;
14
13
 
15
14
  if(saveFile){
16
- try {
17
- timingStart('CSS Compilation of ' + filePath);
18
- const codeData = await plugin.compileScssCode(content, path.dirname(filePath), null, filePath, !isDev);
19
- const endTime = timingStop('CSS Compilation of ' + filePath);
15
+ try {
16
+ const codeData = await plugin.compileScssCode(content, path.dirname(filePath), null, filePath, !isDev);
20
17
 
21
18
  const code = codeData.code;
22
19
  const deps = codeData.dependencies;
@@ -35,7 +32,11 @@ module.exports = async function(content) {
35
32
  }
36
33
 
37
34
  if(fs.existsSync(componentPath)){
38
- fs.writeFileSync(componentPath, fs.readFileSync(componentPath, 'utf-8'))
35
+ const fileCnt = fs.readFileSync(componentPath, 'utf-8');
36
+
37
+ if(fileCnt){
38
+ fs.writeFile(componentPath, fileCnt, () => {})
39
+ }
39
40
  }
40
41
 
41
42
  return '';
@@ -90,7 +90,7 @@ module.exports = async function(content) {
90
90
 
91
91
  if(isDebugged){
92
92
  console.log(chalk.red('[RWS BUILD] Debugging into: ' + debugTsPath));
93
- fs.writeFileSync(debugTsPath, processedContent); //for final RWS TS preview.
93
+ fs.writeFile(debugTsPath, processedContent, () => {}); //for final RWS TS preview.
94
94
  }
95
95
 
96
96
  _scss_cache.cache(customCompilationOptions).cacheItem(filePath, processedContent, cachedCode);
@@ -19,7 +19,7 @@ function writeCssFile(scssFilePath, cssContent) {
19
19
  endCssFilePath[endCssFilePath.length - 1] = `${_COMPILE_DIR_NAME}/` + endCssFilePath[endCssFilePath.length - 1];
20
20
  endCssFilePath = endCssFilePath.join('/');
21
21
 
22
- fs.writeFileSync(endCssFilePath, cssContent);
22
+ fs.writeFile(endCssFilePath, cssContent, () => {});
23
23
  console.log('Saved external CSS file in: ' + endCssFilePath);
24
24
  }
25
25