@pushwoosh/frontend-builder-engine 0.1.8 → 0.2.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.
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module.exports = (api) => {
|
|
2
|
+
api.cache(true);
|
|
3
|
+
return {
|
|
4
|
+
presets: [
|
|
5
|
+
'@babel/preset-env',
|
|
6
|
+
[
|
|
7
|
+
'@babel/preset-react',
|
|
8
|
+
{
|
|
9
|
+
'runtime': 'automatic'
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
'@babel/preset-typescript'
|
|
13
|
+
],
|
|
14
|
+
plugins: [
|
|
15
|
+
[
|
|
16
|
+
'@babel/plugin-transform-runtime',
|
|
17
|
+
{
|
|
18
|
+
'useESModules': true,
|
|
19
|
+
'regenerator': true
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
[
|
|
23
|
+
'babel-plugin-styled-components',
|
|
24
|
+
{
|
|
25
|
+
minify: true,
|
|
26
|
+
transpileTemplateLiterals: true,
|
|
27
|
+
displayName: false,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
],
|
|
31
|
+
}
|
|
32
|
+
}
|
package/lib/pushwoosh-engine.js
CHANGED
|
@@ -10,8 +10,8 @@ const { loadPushwooshConfig } = require('./helpers');
|
|
|
10
10
|
program
|
|
11
11
|
.version('1.0.0')
|
|
12
12
|
.description('An example CLI tool with commander')
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
//.option('-n, --name <type>', 'Your name')
|
|
14
|
+
//.option('-a, --age <type>', 'Your age')
|
|
15
15
|
.command('lib:build')
|
|
16
16
|
.action(async () => {
|
|
17
17
|
const curDir = process.cwd();
|
|
@@ -44,7 +44,11 @@ program
|
|
|
44
44
|
.action(async () => {
|
|
45
45
|
const wpChildProcess = childProcess.spawn(
|
|
46
46
|
'./node_modules/.bin/webpack-dev-server',
|
|
47
|
-
|
|
47
|
+
[
|
|
48
|
+
'--config',
|
|
49
|
+
'./node_modules/@pushwoosh/frontend-builder-engine/lib/webpack.playground.config.js',
|
|
50
|
+
'--stats-error-details',
|
|
51
|
+
],
|
|
48
52
|
{
|
|
49
53
|
cwd: process.cwd(),
|
|
50
54
|
stdio: 'inherit',
|
|
@@ -56,6 +60,38 @@ program
|
|
|
56
60
|
}),
|
|
57
61
|
);
|
|
58
62
|
|
|
63
|
+
program
|
|
64
|
+
.addCommand(
|
|
65
|
+
new Command('app:dev:get')
|
|
66
|
+
.description('App')
|
|
67
|
+
.action(async () => {
|
|
68
|
+
const cmd = [
|
|
69
|
+
'./node_modules/.bin/webpack',
|
|
70
|
+
'--config',
|
|
71
|
+
'./node_modules/@pushwoosh/frontend-builder-engine/lib/webpack.application.config.js',
|
|
72
|
+
'--stats-error-details',
|
|
73
|
+
'serve',
|
|
74
|
+
];
|
|
75
|
+
console.log(cmd.join(' '));
|
|
76
|
+
}),
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
program
|
|
80
|
+
.addCommand(
|
|
81
|
+
new Command('app:build:get')
|
|
82
|
+
.description('App')
|
|
83
|
+
.action(async () => {
|
|
84
|
+
const cmd = [
|
|
85
|
+
'./node_modules/.bin/webpack',
|
|
86
|
+
'--config',
|
|
87
|
+
'./node_modules/@pushwoosh/frontend-builder-engine/lib/webpack.application.config.js',
|
|
88
|
+
'--stats-error-details',
|
|
89
|
+
'--mode=production'
|
|
90
|
+
];
|
|
91
|
+
console.log(cmd.join(' '));
|
|
92
|
+
}),
|
|
93
|
+
);
|
|
94
|
+
|
|
59
95
|
const pushwooshConfig = loadPushwooshConfig();
|
|
60
96
|
if (pushwooshConfig.program) {
|
|
61
97
|
pushwooshConfig.program(program);
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const webpack = require('webpack');
|
|
3
|
+
const { mergeWithCustomize } = require('webpack-merge');
|
|
4
|
+
const singleSpaDefaults = require('webpack-config-single-spa-react-ts');
|
|
5
|
+
|
|
6
|
+
const { loadVariables, getGuardedVariable } = require('./webpack.utilities');
|
|
7
|
+
|
|
8
|
+
module.exports = (webpackConfigEnv, argv) => {
|
|
9
|
+
const cwd = process.cwd();
|
|
10
|
+
|
|
11
|
+
const packageJson = require(path.resolve(cwd, 'package.json'));
|
|
12
|
+
|
|
13
|
+
const orgName = packageJson.name.split('/')[0].replace('@', '');
|
|
14
|
+
const projectName = packageJson.name.split('/')[1];
|
|
15
|
+
const peerDependencies = packageJson.peerDependencies || {};
|
|
16
|
+
const peerDependenciesList = Object.keys(peerDependencies);
|
|
17
|
+
|
|
18
|
+
const NODE_ENV = argv.mode || 'development';
|
|
19
|
+
const isProduction = NODE_ENV === 'production';
|
|
20
|
+
const variables = loadVariables(!isProduction);
|
|
21
|
+
|
|
22
|
+
const defaultConfig = singleSpaDefaults({
|
|
23
|
+
orgName,
|
|
24
|
+
projectName,
|
|
25
|
+
webpackConfigEnv,
|
|
26
|
+
argv,
|
|
27
|
+
orgPackagesAsExternal: false,
|
|
28
|
+
rootDirectoryLevel: 1,
|
|
29
|
+
disableHtmlGeneration: true,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const extend = {
|
|
33
|
+
entry: {
|
|
34
|
+
index: path.resolve(cwd, './src/index.tsx'),
|
|
35
|
+
},
|
|
36
|
+
output: {
|
|
37
|
+
filename: '[name].js',
|
|
38
|
+
path: path.resolve(cwd, './dist'),
|
|
39
|
+
},
|
|
40
|
+
resolve: {
|
|
41
|
+
alias: {
|
|
42
|
+
'~/src': path.resolve(cwd, './src'),
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
externals: peerDependenciesList,
|
|
46
|
+
plugins: [
|
|
47
|
+
new webpack.DefinePlugin({
|
|
48
|
+
process: {
|
|
49
|
+
env: JSON.stringify({
|
|
50
|
+
NODE_ENV,
|
|
51
|
+
VERSION: getGuardedVariable(variables, 'VERSION', isProduction),
|
|
52
|
+
}),
|
|
53
|
+
},
|
|
54
|
+
}),
|
|
55
|
+
],
|
|
56
|
+
};
|
|
57
|
+
if (!isProduction) {
|
|
58
|
+
extend.devServer = {
|
|
59
|
+
port: getGuardedVariable(variables, 'DEV_SERVER_PORT', true),
|
|
60
|
+
server: {
|
|
61
|
+
type: 'https',
|
|
62
|
+
options: {
|
|
63
|
+
key: getGuardedVariable(variables, 'DEV_SERVER_KEY_PEM_PATH', true),
|
|
64
|
+
cert: getGuardedVariable(variables, 'DEV_SERVER_CERT_PEM_PATH', true),
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
headers: {
|
|
68
|
+
'Access-Control-Allow-Origin': '*',
|
|
69
|
+
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
|
|
70
|
+
'Access-Control-Allow-Headers': 'X-Requested-With, Content-Type, Authorization',
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
//console.log(peerDependenciesList);
|
|
75
|
+
return mergeWithCustomize({
|
|
76
|
+
customizeArray(a, b, key) {
|
|
77
|
+
if (key === 'externals') {
|
|
78
|
+
return [...a, ...b].filter((item) => !['react', 'react-dom'].includes(item));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return undefined;
|
|
82
|
+
},
|
|
83
|
+
})(defaultConfig, extend);
|
|
84
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const dotenv = require('dotenv');
|
|
2
|
+
|
|
3
|
+
function loadVariables(loadLocal) {
|
|
4
|
+
let variables = process.env;
|
|
5
|
+
if (loadLocal) {
|
|
6
|
+
const { error, parsed } = dotenv.config();
|
|
7
|
+
if (error) {
|
|
8
|
+
throw error;
|
|
9
|
+
}
|
|
10
|
+
variables = parsed;
|
|
11
|
+
}
|
|
12
|
+
console.log('variables', variables);
|
|
13
|
+
return variables;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function getGuardedVariable(object, key, strict) {
|
|
17
|
+
const variable = object[key];
|
|
18
|
+
if (typeof variable !== 'string') {
|
|
19
|
+
if (strict) {
|
|
20
|
+
throw new Error(`${key} is not defined!`);
|
|
21
|
+
}
|
|
22
|
+
return '';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return variable;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = {
|
|
29
|
+
loadVariables,
|
|
30
|
+
getGuardedVariable,
|
|
31
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushwoosh/frontend-builder-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Pushwoosh frontend builder engine",
|
|
5
5
|
"main": "./lib/pushwoosh-frontend-builder-engine.js",
|
|
6
6
|
"scripts": {
|
|
@@ -15,21 +15,34 @@
|
|
|
15
15
|
"README.md"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
+
"@babel/cli": "^7.24.1",
|
|
18
19
|
"@babel/core": "^7.24.3",
|
|
20
|
+
"@babel/plugin-transform-runtime": "^7.24.3",
|
|
21
|
+
"@babel/preset-env": "^7.24.3",
|
|
22
|
+
"@babel/preset-react": "^7.24.1",
|
|
23
|
+
"@babel/preset-typescript": "^7.24.1",
|
|
24
|
+
"@babel/types": "^7.24.0",
|
|
25
|
+
"@types/webpack-env": "^1.18.4",
|
|
26
|
+
"babel-loader": "^9.1.3",
|
|
19
27
|
"babel-plugin-styled-components": "^2.1.4",
|
|
20
28
|
"babel-plugin-transform-imports": "^2.0.0",
|
|
21
29
|
"commander": "^12.0.0",
|
|
22
30
|
"dotenv": "^16.4.5",
|
|
23
31
|
"html-webpack-plugin": "^5.6.0",
|
|
32
|
+
"ts-config-single-spa": "^3.0.0",
|
|
24
33
|
"ts-loader": "^9.5.1",
|
|
25
34
|
"tsconfig-paths-webpack-plugin": "^4.1.0",
|
|
26
35
|
"typescript": "^5.0.0",
|
|
27
36
|
"webpack": "^5.91.0",
|
|
37
|
+
"webpack-bundle-analyzer": "^4.10.1",
|
|
28
38
|
"webpack-cli": "^5.1.4",
|
|
39
|
+
"webpack-config-single-spa": "^5.3.1",
|
|
40
|
+
"webpack-config-single-spa-react": "^4.0.5",
|
|
41
|
+
"webpack-config-single-spa-react-ts": "^4.0.5",
|
|
42
|
+
"webpack-config-single-spa-ts": "^4.1.4",
|
|
29
43
|
"webpack-dev-server": "^5.0.4"
|
|
30
44
|
},
|
|
31
45
|
"peerDependencies": {
|
|
32
|
-
"@types/webpack-env": "^1.18.4",
|
|
33
46
|
"lodash": "^4.0.0",
|
|
34
47
|
"typescript": "^5.0.0"
|
|
35
48
|
},
|