@pushwoosh/frontend-builder-engine 1.0.22 → 2.0.0-beta
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,156 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
|
3
|
+
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
|
4
|
+
const SystemJSPublicPathPlugin = require('systemjs-webpack-interop/SystemJSPublicPathWebpackPlugin');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Single-spa webpack configuration for React + TypeScript applications.
|
|
8
|
+
* Replaces webpack-config-single-spa-react-ts package.
|
|
9
|
+
*/
|
|
10
|
+
function singleSpaDefaults(opts) {
|
|
11
|
+
if (typeof opts !== 'object') {
|
|
12
|
+
throw Error('single-spa-defaults requires an opts object');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (typeof opts.orgName !== 'string') {
|
|
16
|
+
throw Error('single-spa-defaults requires an opts.orgName string');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (typeof opts.projectName !== 'string') {
|
|
20
|
+
throw Error('single-spa-defaults requires an opts.projectName string');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (opts.orgPackagesAsExternal !== false) {
|
|
24
|
+
opts.orgPackagesAsExternal = true;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const webpackConfigEnv = opts.webpackConfigEnv || {};
|
|
28
|
+
const argv = opts.argv || {};
|
|
29
|
+
const isProduction = argv.p || argv.mode === 'production';
|
|
30
|
+
const isAnalyze = webpackConfigEnv.analyze;
|
|
31
|
+
|
|
32
|
+
// Base externals
|
|
33
|
+
const externals = opts.orgPackagesAsExternal
|
|
34
|
+
? ['single-spa', new RegExp(`^@${opts.orgName}/`)]
|
|
35
|
+
: ['single-spa'];
|
|
36
|
+
|
|
37
|
+
// Add React externals (unless standalone mode)
|
|
38
|
+
if (!webpackConfigEnv.standalone) {
|
|
39
|
+
externals.push('react', 'react-dom');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Plugins
|
|
43
|
+
const plugins = [
|
|
44
|
+
new BundleAnalyzerPlugin({
|
|
45
|
+
analyzerMode: isAnalyze ? 'server' : 'disabled',
|
|
46
|
+
}),
|
|
47
|
+
new SystemJSPublicPathPlugin({
|
|
48
|
+
systemjsModuleName: `@${opts.orgName}/${opts.projectName}`,
|
|
49
|
+
rootDirectoryLevel: opts.rootDirectoryLevel,
|
|
50
|
+
}),
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
// Add TypeScript checker (skip in analyze mode)
|
|
54
|
+
if (!isAnalyze) {
|
|
55
|
+
plugins.push(
|
|
56
|
+
new ForkTsCheckerWebpackPlugin({
|
|
57
|
+
typescript: {
|
|
58
|
+
mode: 'write-references',
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
mode: isProduction ? 'production' : 'development',
|
|
66
|
+
entry: path.resolve(
|
|
67
|
+
process.cwd(),
|
|
68
|
+
`src/${opts.orgName}-${opts.projectName}.tsx`,
|
|
69
|
+
),
|
|
70
|
+
output: {
|
|
71
|
+
filename: `${opts.orgName}-${opts.projectName}.js`,
|
|
72
|
+
libraryTarget: 'system',
|
|
73
|
+
path: path.resolve(process.cwd(), 'dist'),
|
|
74
|
+
uniqueName: opts.projectName,
|
|
75
|
+
devtoolNamespace: opts.projectName,
|
|
76
|
+
publicPath: '',
|
|
77
|
+
},
|
|
78
|
+
module: {
|
|
79
|
+
rules: [
|
|
80
|
+
{
|
|
81
|
+
test: /\.(js|ts)x?$/,
|
|
82
|
+
exclude: /node_modules/,
|
|
83
|
+
use: {
|
|
84
|
+
loader: require.resolve('babel-loader'),
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
test: /\.css$/i,
|
|
89
|
+
include: [/node_modules/, /src/],
|
|
90
|
+
exclude: [/\.module\.css$/],
|
|
91
|
+
use: [
|
|
92
|
+
{
|
|
93
|
+
loader: require.resolve('style-loader'),
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
loader: require.resolve('css-loader'),
|
|
97
|
+
options: {
|
|
98
|
+
modules: false,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
test: /\.module\.css$/i,
|
|
105
|
+
exclude: [/node_modules/],
|
|
106
|
+
use: [
|
|
107
|
+
{
|
|
108
|
+
loader: require.resolve('style-loader'),
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
loader: require.resolve('css-loader'),
|
|
112
|
+
options: {
|
|
113
|
+
modules: true,
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
test: /\.(bmp|png|jpg|jpeg|gif|webp)$/i,
|
|
120
|
+
exclude: /node_modules/,
|
|
121
|
+
type: 'asset/resource',
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
test: /\.svg$/i,
|
|
125
|
+
exclude: /node_modules/,
|
|
126
|
+
type: 'asset/resource',
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
test: /\.html$/i,
|
|
130
|
+
exclude: [/node_modules/, /\.vue\.html$/],
|
|
131
|
+
type: 'asset/source',
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
},
|
|
135
|
+
devtool: 'source-map',
|
|
136
|
+
devServer: {
|
|
137
|
+
historyApiFallback: true,
|
|
138
|
+
headers: {
|
|
139
|
+
'Access-Control-Allow-Origin': '*',
|
|
140
|
+
},
|
|
141
|
+
client: {
|
|
142
|
+
webSocketURL: {
|
|
143
|
+
hostname: 'localhost',
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
allowedHosts: 'all',
|
|
147
|
+
},
|
|
148
|
+
externals,
|
|
149
|
+
plugins: plugins.filter(Boolean),
|
|
150
|
+
resolve: {
|
|
151
|
+
extensions: ['.ts', '.tsx', '.mjs', '.js', '.jsx', '.wasm', '.json'],
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
module.exports = singleSpaDefaults;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
|
|
3
3
|
const webpack = require('webpack');
|
|
4
|
-
const singleSpaDefaults = require('webpack-config
|
|
4
|
+
const singleSpaDefaults = require('./webpack-config/single-spa-defaults');
|
|
5
5
|
const { merge } = require('webpack-merge');
|
|
6
6
|
|
|
7
7
|
const { loadPushwooshConfig } = require('./helpers');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushwoosh/frontend-builder-engine",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta",
|
|
4
4
|
"description": "Pushwoosh frontend builder engine",
|
|
5
5
|
"main": "./lib/pushwoosh-frontend-builder-engine.js",
|
|
6
6
|
"scripts": {
|
|
@@ -38,8 +38,9 @@
|
|
|
38
38
|
"eslint-plugin-react": "^7.37.2",
|
|
39
39
|
"eslint-plugin-react-hooks": "^5.0.0",
|
|
40
40
|
"html-webpack-plugin": "^5.6.0",
|
|
41
|
+
"fork-ts-checker-webpack-plugin": "^9.0.2",
|
|
41
42
|
"style-loader": "^3.3.4",
|
|
42
|
-
"
|
|
43
|
+
"systemjs-webpack-interop": "^2.3.7",
|
|
43
44
|
"ts-loader": "^9.5.1",
|
|
44
45
|
"tsconfig-paths-webpack-plugin": "^4.1.0",
|
|
45
46
|
"typescript": "^5.5.4",
|
|
@@ -47,11 +48,8 @@
|
|
|
47
48
|
"webpack": "^5.94.0",
|
|
48
49
|
"webpack-bundle-analyzer": "^4.10.1",
|
|
49
50
|
"webpack-cli": "^5.1.4",
|
|
50
|
-
"webpack-
|
|
51
|
-
"webpack-
|
|
52
|
-
"webpack-config-single-spa-react-ts": "^4.0.5",
|
|
53
|
-
"webpack-config-single-spa-ts": "^4.1.4",
|
|
54
|
-
"webpack-dev-server": "^5.0.4"
|
|
51
|
+
"webpack-dev-server": "^5.0.4",
|
|
52
|
+
"webpack-merge": "^5.10.0"
|
|
55
53
|
},
|
|
56
54
|
"peerDependencies": {
|
|
57
55
|
"lodash": "^4.0.0",
|
|
@@ -59,13 +57,5 @@
|
|
|
59
57
|
},
|
|
60
58
|
"devDependencies": {
|
|
61
59
|
"@types/typescript": "^2.0.0"
|
|
62
|
-
},
|
|
63
|
-
"overrides": {
|
|
64
|
-
"webpack-config-single-spa": {
|
|
65
|
-
"babel-loader": "^9.1.3"
|
|
66
|
-
},
|
|
67
|
-
"webpack-config-single-spa-ts": {
|
|
68
|
-
"typescript": "^5.0.0"
|
|
69
|
-
}
|
|
70
60
|
}
|
|
71
61
|
}
|