zephyr-webpack-plugin 0.0.49 → 0.0.51
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/README.md +209 -8
- package/dist/package.json +1 -1
- package/dist/webpack-plugin/with-zephyr.js +1 -1
- package/dist/webpack-plugin/with-zephyr.js.map +1 -1
- package/dist/webpack-plugin/ze-webpack-plugin.js +1 -0
- package/dist/webpack-plugin/ze-webpack-plugin.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,44 +1,245 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Zephyr Webpack Plugin
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
|
|
5
|
-
[Zephyr Cloud](https://zephyr-cloud.io) | [Zephyr Docs](https://docs.zephyr-cloud.io/recipes/
|
|
5
|
+
[Zephyr Cloud](https://zephyr-cloud.io) | [Zephyr Docs](https://docs.zephyr-cloud.io/recipes/) | [Discord](https://zephyr-cloud.io/discord) | [Twitter](https://x.com/ZephyrCloudIO) | [LinkedIn](https://www.linkedin.com/company/zephyr-cloud/)
|
|
6
6
|
|
|
7
7
|
<hr/>
|
|
8
|
+
<img src="https://cdn.prod.website-files.com/669061ee3adb95b628c3acda/66981c766e352fe1f57191e2_Opengraph-zephyr.png" alt="Zephyr Logo" />
|
|
8
9
|
</div>
|
|
9
10
|
|
|
11
|
+
A Webpack plugin for deploying applications with Zephyr Cloud. This plugin integrates seamlessly with Webpack's ecosystem to enable deployment of your applications with comprehensive Module Federation support.
|
|
12
|
+
|
|
13
|
+
For more information please refer to our [documentation](https://docs.zephyr-cloud.io/recipes).
|
|
14
|
+
|
|
10
15
|
## Installation
|
|
11
16
|
|
|
12
|
-
```
|
|
17
|
+
```bash
|
|
13
18
|
# npm
|
|
14
19
|
npm install --save-dev zephyr-webpack-plugin
|
|
20
|
+
|
|
15
21
|
# yarn
|
|
16
22
|
yarn add --dev zephyr-webpack-plugin
|
|
23
|
+
|
|
17
24
|
# pnpm
|
|
18
25
|
pnpm add --dev zephyr-webpack-plugin
|
|
26
|
+
|
|
19
27
|
# bun
|
|
20
28
|
bun add --dev zephyr-webpack-plugin
|
|
21
29
|
```
|
|
22
30
|
|
|
23
31
|
## Usage
|
|
24
32
|
|
|
25
|
-
### With Nx
|
|
33
|
+
### With Nx and Webpack
|
|
34
|
+
|
|
35
|
+
For Nx projects using Webpack:
|
|
36
|
+
|
|
37
|
+
```javascript
|
|
38
|
+
// webpack.config.js
|
|
39
|
+
import { composePlugins, withNx } from '@nx/webpack';
|
|
40
|
+
import { withReact } from '@nx/react';
|
|
41
|
+
import { withModuleFederation } from '@nx/webpack/module-federation';
|
|
42
|
+
import { withZephyr } from 'zephyr-webpack-plugin';
|
|
43
|
+
|
|
44
|
+
const mfConfig = {
|
|
45
|
+
name: 'my-app',
|
|
46
|
+
remotes: {
|
|
47
|
+
'shared-ui': 'shared_ui@http://localhost:3001/remoteEntry.js',
|
|
48
|
+
},
|
|
49
|
+
shared: {
|
|
50
|
+
react: { singleton: true },
|
|
51
|
+
'react-dom': { singleton: true },
|
|
52
|
+
},
|
|
53
|
+
};
|
|
26
54
|
|
|
27
|
-
```
|
|
28
55
|
export default composePlugins(
|
|
29
56
|
withNx(),
|
|
30
57
|
withReact(),
|
|
31
58
|
withModuleFederation(mfConfig),
|
|
32
|
-
withZephyr(),
|
|
59
|
+
withZephyr(), // Add Zephyr plugin
|
|
33
60
|
(config) => {
|
|
34
61
|
return config;
|
|
35
62
|
}
|
|
36
63
|
);
|
|
37
64
|
```
|
|
38
65
|
|
|
39
|
-
### With Webpack
|
|
66
|
+
### With Webpack Directly
|
|
67
|
+
|
|
68
|
+
For standalone Webpack projects:
|
|
40
69
|
|
|
70
|
+
```javascript
|
|
71
|
+
// webpack.config.js
|
|
72
|
+
const { withZephyr } = require('zephyr-webpack-plugin');
|
|
73
|
+
|
|
74
|
+
const config = {
|
|
75
|
+
entry: './src/index.js',
|
|
76
|
+
output: {
|
|
77
|
+
path: path.resolve(__dirname, 'dist'),
|
|
78
|
+
filename: '[name].[contenthash].js',
|
|
79
|
+
},
|
|
80
|
+
// ... other Webpack configuration
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
module.exports = withZephyr()(config);
|
|
41
84
|
```
|
|
42
|
-
module.exports = withZephyr()(your_webpack_config);
|
|
43
85
|
|
|
86
|
+
### TypeScript Configuration
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
// webpack.config.ts
|
|
90
|
+
import { Configuration } from 'webpack';
|
|
91
|
+
import { withZephyr } from 'zephyr-webpack-plugin';
|
|
92
|
+
|
|
93
|
+
const config: Configuration = {
|
|
94
|
+
entry: './src/index.tsx',
|
|
95
|
+
output: {
|
|
96
|
+
path: path.resolve(__dirname, 'dist'),
|
|
97
|
+
filename: '[name].[contenthash].js',
|
|
98
|
+
},
|
|
99
|
+
// ... other configuration
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export default withZephyr({
|
|
103
|
+
// Zephyr options
|
|
104
|
+
deploy: true,
|
|
105
|
+
environment: 'production',
|
|
106
|
+
})(config);
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### With Module Federation Plugin
|
|
110
|
+
|
|
111
|
+
```javascript
|
|
112
|
+
// webpack.config.js
|
|
113
|
+
const ModuleFederationPlugin = require('@module-federation/webpack');
|
|
114
|
+
const { withZephyr } = require('zephyr-webpack-plugin');
|
|
115
|
+
|
|
116
|
+
const config = {
|
|
117
|
+
entry: './src/index.js',
|
|
118
|
+
plugins: [
|
|
119
|
+
new ModuleFederationPlugin({
|
|
120
|
+
name: 'host',
|
|
121
|
+
remotes: {
|
|
122
|
+
mfe1: 'mfe1@http://localhost:3001/remoteEntry.js',
|
|
123
|
+
},
|
|
124
|
+
shared: {
|
|
125
|
+
react: { singleton: true },
|
|
126
|
+
'react-dom': { singleton: true },
|
|
127
|
+
},
|
|
128
|
+
}),
|
|
129
|
+
],
|
|
130
|
+
// ... other configuration
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
module.exports = withZephyr()(config);
|
|
44
134
|
```
|
|
135
|
+
|
|
136
|
+
## Features
|
|
137
|
+
|
|
138
|
+
- 🏗️ Full Module Federation support with Webpack 5
|
|
139
|
+
- 📦 Automatic asset optimization and caching
|
|
140
|
+
- 🔧 Zero-config setup for simple applications
|
|
141
|
+
- 📊 Build analytics and monitoring
|
|
142
|
+
- 🌐 Global CDN distribution
|
|
143
|
+
- ⚡ Hot module replacement in development
|
|
144
|
+
- 🎯 Nx integration for monorepo support
|
|
145
|
+
- 🔗 Automatic vendor federation for shared dependencies
|
|
146
|
+
|
|
147
|
+
## Module Federation Support
|
|
148
|
+
|
|
149
|
+
This plugin provides comprehensive Module Federation support:
|
|
150
|
+
|
|
151
|
+
- **Host Applications**: Consume remote modules from other applications
|
|
152
|
+
- **Remote Applications**: Expose modules for consumption by host applications
|
|
153
|
+
- **Shared Dependencies**: Efficient sharing of common libraries
|
|
154
|
+
- **Dynamic Imports**: Runtime loading of remote modules
|
|
155
|
+
- **Automatic Vendor Federation**: Smart dependency sharing
|
|
156
|
+
- **Federation Dashboard**: Build-time federation analytics
|
|
157
|
+
|
|
158
|
+
## Getting Started
|
|
159
|
+
|
|
160
|
+
1. Install the plugin in your Webpack project
|
|
161
|
+
2. Add it to your Webpack configuration
|
|
162
|
+
3. Configure Module Federation (if needed) for microfrontends
|
|
163
|
+
4. Build your application with `npm run build`
|
|
164
|
+
5. Your app will be automatically deployed to Zephyr Cloud
|
|
165
|
+
|
|
166
|
+
## Build Scripts
|
|
167
|
+
|
|
168
|
+
Add these scripts to your `package.json`:
|
|
169
|
+
|
|
170
|
+
```json
|
|
171
|
+
{
|
|
172
|
+
"scripts": {
|
|
173
|
+
"dev": "webpack serve",
|
|
174
|
+
"build": "webpack",
|
|
175
|
+
"build:prod": "NODE_ENV=production webpack"
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Advanced Configuration
|
|
181
|
+
|
|
182
|
+
### Custom Webpack Configuration
|
|
183
|
+
|
|
184
|
+
```javascript
|
|
185
|
+
// webpack.config.js
|
|
186
|
+
const { withZephyr } = require('zephyr-webpack-plugin');
|
|
187
|
+
|
|
188
|
+
const config = {
|
|
189
|
+
entry: './src/index.js',
|
|
190
|
+
optimization: {
|
|
191
|
+
splitChunks: {
|
|
192
|
+
chunks: 'all',
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
resolve: {
|
|
196
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
197
|
+
},
|
|
198
|
+
module: {
|
|
199
|
+
rules: [
|
|
200
|
+
{
|
|
201
|
+
test: /\.(js|jsx|ts|tsx)$/,
|
|
202
|
+
exclude: /node_modules/,
|
|
203
|
+
use: 'babel-loader',
|
|
204
|
+
},
|
|
205
|
+
],
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
module.exports = withZephyr({
|
|
210
|
+
deploy: process.env.NODE_ENV === 'production',
|
|
211
|
+
environment: process.env.NODE_ENV || 'development',
|
|
212
|
+
})(config);
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Requirements
|
|
216
|
+
|
|
217
|
+
- Webpack 5.x or higher
|
|
218
|
+
- Node.js 18 or higher
|
|
219
|
+
- Zephyr Cloud account (sign up at [zephyr-cloud.io](https://zephyr-cloud.io))
|
|
220
|
+
|
|
221
|
+
## Examples
|
|
222
|
+
|
|
223
|
+
Check out our [examples directory](../../examples/) for complete working examples:
|
|
224
|
+
|
|
225
|
+
- [sample-webpack-application](../../examples/sample-webpack-application/) - Basic Webpack setup
|
|
226
|
+
- [react-micro-frontends](../../examples/react-micro-frontends/) - Module Federation setup with multiple teams
|
|
227
|
+
|
|
228
|
+
## Nx Integration
|
|
229
|
+
|
|
230
|
+
This plugin works seamlessly with Nx workspaces:
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
# Generate a new Webpack app with Module Federation
|
|
234
|
+
nx g @nx/react:app my-app --bundler=webpack --mf=true
|
|
235
|
+
|
|
236
|
+
# Add Zephyr plugin to the generated configuration
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Contributing
|
|
240
|
+
|
|
241
|
+
We welcome contributions! Please read our [contributing guidelines](../../CONTRIBUTING.md) for more information.
|
|
242
|
+
|
|
243
|
+
## License
|
|
244
|
+
|
|
245
|
+
Licensed under the Apache-2.0 License. See [LICENSE](LICENSE) for more information.
|
package/dist/package.json
CHANGED
|
@@ -19,7 +19,7 @@ async function _zephyr_configuration(config, _zephyrOptions) {
|
|
|
19
19
|
const resolved_dependency_pairs = await zephyr_engine.resolve_remote_dependencies(dependencyPairs);
|
|
20
20
|
(0, zephyr_xpack_internal_1.mutWebpackFederatedRemotesConfig)(zephyr_engine, config, resolved_dependency_pairs);
|
|
21
21
|
const mfConfig = (0, zephyr_xpack_internal_1.makeCopyOfModuleFederationOptions)(config);
|
|
22
|
-
|
|
22
|
+
zephyr_agent_1.ze_log.mf(`with-zephyr.mfConfig: ${JSON.stringify(mfConfig, null, 2)}`);
|
|
23
23
|
// inject the ZephyrWebpackPlugin
|
|
24
24
|
config.plugins?.push(new ze_webpack_plugin_1.ZeWebpackPlugin({
|
|
25
25
|
zephyr_engine,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-zephyr.js","sourceRoot":"","sources":["../../src/webpack-plugin/with-zephyr.ts"],"names":[],"mappings":";;AAWA,gCAEC;AAZD,+CAAwE;AACxE,iEAI+B;AAG/B,2DAAsD;AAEtD,SAAgB,UAAU,CAAC,mBAAgD;IACzE,OAAO,CAAC,MAAqB,EAAE,EAAE,CAAC,qBAAqB,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;AACvF,CAAC;AAED,KAAK,UAAU,qBAAqB,CAClC,MAA4B,EAC5B,cAA2C;IAE3C,IAAI,CAAC;QACH,2DAA2D;QAC3D,MAAM,aAAa,GAAG,MAAM,2BAAY,CAAC,MAAM,CA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I,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QAExE,iCAAiC;QACjC,MAAM,CAAC,OAAO,EAAE,IAAI,CAClB,IAAI,mCAAe,CAAC;YAClB,aAAa;YACb,QAAQ,EAAE,QAAQ;YAClB,mBAAmB,EAAE,cAAc,EAAE,mBAAmB;SACzD,CAAC,CACH,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAA,oBAAK,EAAC,OAAO,EAAE,0BAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -9,6 +9,7 @@ class ZeWebpackPlugin {
|
|
|
9
9
|
}
|
|
10
10
|
apply(compiler) {
|
|
11
11
|
this._options.zephyr_engine.buildProperties.output = compiler.outputPath;
|
|
12
|
+
(0, zephyr_xpack_internal_1.detectAndStoreBaseHref)(this._options.zephyr_engine, compiler);
|
|
12
13
|
(0, zephyr_xpack_internal_1.logBuildSteps)(this._options, compiler);
|
|
13
14
|
(0, zephyr_xpack_internal_1.setupZeDeploy)(this._options, compiler);
|
|
14
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ze-webpack-plugin.js","sourceRoot":"","sources":["../../src/webpack-plugin/ze-webpack-plugin.ts"],"names":[],"mappings":";;;AAIA,
|
|
1
|
+
{"version":3,"file":"ze-webpack-plugin.js","sourceRoot":"","sources":["../../src/webpack-plugin/ze-webpack-plugin.ts"],"names":[],"mappings":";;;AAIA,iEAI+B;AAE/B,MAAM,UAAU,GAAG,iBAAiB,CAAC;AAarC,MAAa,eAAe;IAG1B,YAAY,OAA+D;QACzE,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,QAAkB;QACtB,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,eAAe,CAAC,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC;QACzE,IAAA,8CAAsB,EAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;QAC9D,IAAA,qCAAa,EAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACvC,IAAA,qCAAa,EAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACzC,CAAC;CACF;AAbD,0CAaC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zephyr-webpack-plugin",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.51",
|
|
4
4
|
"description": "Webpack plugin for Zephyr",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"is-ci": "^4.1.0",
|
|
21
21
|
"tslib": "^2.8.1",
|
|
22
22
|
"webpack": "^5.98.0",
|
|
23
|
-
"zephyr-
|
|
24
|
-
"zephyr-
|
|
23
|
+
"zephyr-xpack-internal": "0.0.51",
|
|
24
|
+
"zephyr-agent": "0.0.51"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/is-ci": "3.0.4",
|