zephyr-rolldown-plugin 0.0.0-canary.65 → 0.0.0-canary.67
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 +24 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +40 -4
- package/dist/index.mjs +2 -0
- package/dist/lib/internal/get-assets-map.d.mts +4 -0
- package/dist/lib/internal/get-assets-map.d.ts +1 -0
- package/dist/lib/internal/get-assets-map.js +46 -11
- package/dist/lib/internal/get-assets-map.mjs +19 -0
- package/dist/lib/zephyr-rolldown-plugin.d.mts +19 -0
- package/dist/lib/zephyr-rolldown-plugin.d.ts +14 -4
- package/dist/lib/zephyr-rolldown-plugin.js +136 -30
- package/dist/lib/zephyr-rolldown-plugin.mjs +117 -0
- package/package.json +44 -19
- package/dist/index.js.map +0 -1
- package/dist/lib/internal/get-assets-map.js.map +0 -1
- package/dist/lib/zephyr-rolldown-plugin.js.map +0 -1
- package/dist/package.json +0 -38
- package/eslint.config.mjs +0 -3
package/README.md
CHANGED
|
@@ -81,6 +81,30 @@ export default defineConfig({
|
|
|
81
81
|
});
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
+
### TAP Module Federation metadata
|
|
85
|
+
|
|
86
|
+
Rolldown does not discover independently published TAP containers. For a `tap-app`
|
|
87
|
+
build, pass the SDK-produced config and build-stat records together:
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
withZephyr({
|
|
91
|
+
target: 'tap-app',
|
|
92
|
+
mfConfigs: [
|
|
93
|
+
{ name: 'desktop', filename: 'targets/desktop/remoteEntry.mjs' },
|
|
94
|
+
{ name: 'quickjs', filename: 'targets/quickjs/remoteEntry.mjs' },
|
|
95
|
+
],
|
|
96
|
+
federation: [
|
|
97
|
+
{ name: 'desktop', remote: 'targets/desktop/remoteEntry.mjs', library_type: 'module' },
|
|
98
|
+
{ name: 'quickjs', remote: 'targets/quickjs/remoteEntry.mjs', library_type: 'module' },
|
|
99
|
+
],
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Both arrays must be non-empty, have the same containers, and pair each `name` with
|
|
104
|
+
`filename === remote`. The plugin rejects incomplete or mismatched TAP metadata. A
|
|
105
|
+
single valid container also supplies the legacy `mfConfig`; multi-container builds
|
|
106
|
+
retain only the full arrays rather than choosing an arbitrary container.
|
|
107
|
+
|
|
84
108
|
## Features
|
|
85
109
|
|
|
86
110
|
- 🚀 Automatic deployment during build
|
package/dist/index.d.mts
ADDED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
withZephyr: ()=>zephyr_rolldown_plugin_js_namespaceObject.withZephyr
|
|
32
|
+
});
|
|
33
|
+
const zephyr_rolldown_plugin_js_namespaceObject = require("./lib/zephyr-rolldown-plugin.js");
|
|
34
|
+
exports.withZephyr = __webpack_exports__.withZephyr;
|
|
35
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
36
|
+
"withZephyr"
|
|
37
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
38
|
+
Object.defineProperty(exports, '__esModule', {
|
|
39
|
+
value: true
|
|
40
|
+
});
|
|
41
|
+
|
|
6
42
|
//# sourceMappingURL=index.js.map
|
package/dist/index.mjs
ADDED
|
@@ -1,21 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
getAssetsMap: ()=>getAssetsMap
|
|
32
|
+
});
|
|
33
|
+
const external_zephyr_agent_namespaceObject = require("zephyr-agent");
|
|
5
34
|
function getAssetsMap(assets) {
|
|
6
|
-
return (0,
|
|
35
|
+
return (0, external_zephyr_agent_namespaceObject.buildAssetsMap)(assets, extractBuffer, getAssetType);
|
|
7
36
|
}
|
|
8
|
-
const extractBuffer = (asset)
|
|
9
|
-
switch
|
|
37
|
+
const extractBuffer = (asset)=>{
|
|
38
|
+
switch(asset.type){
|
|
10
39
|
case 'chunk':
|
|
11
40
|
return asset.code;
|
|
12
41
|
case 'asset':
|
|
13
|
-
return typeof asset.source
|
|
14
|
-
? asset.source
|
|
15
|
-
: new TextDecoder().decode(asset.source);
|
|
42
|
+
return 'string' == typeof asset.source ? asset.source : Buffer.from(asset.source);
|
|
16
43
|
default:
|
|
17
|
-
return
|
|
44
|
+
return;
|
|
18
45
|
}
|
|
19
46
|
};
|
|
20
|
-
const getAssetType = (asset)
|
|
47
|
+
const getAssetType = (asset)=>asset.type;
|
|
48
|
+
exports.getAssetsMap = __webpack_exports__.getAssetsMap;
|
|
49
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
50
|
+
"getAssetsMap"
|
|
51
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
52
|
+
Object.defineProperty(exports, '__esModule', {
|
|
53
|
+
value: true
|
|
54
|
+
});
|
|
55
|
+
|
|
21
56
|
//# sourceMappingURL=get-assets-map.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { buildAssetsMap } from "zephyr-agent";
|
|
3
|
+
function getAssetsMap(assets) {
|
|
4
|
+
return buildAssetsMap(assets, extractBuffer, getAssetType);
|
|
5
|
+
}
|
|
6
|
+
const extractBuffer = (asset)=>{
|
|
7
|
+
switch(asset.type){
|
|
8
|
+
case 'chunk':
|
|
9
|
+
return asset.code;
|
|
10
|
+
case 'asset':
|
|
11
|
+
return 'string' == typeof asset.source ? asset.source : Buffer.from(asset.source);
|
|
12
|
+
default:
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const getAssetType = (asset)=>asset.type;
|
|
17
|
+
export { getAssetsMap };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=get-assets-map.mjs.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { InputOptions, NormalizedOutputOptions, OutputBundle } from 'rolldown';
|
|
2
|
+
import { type ZephyrBuildHooks, type ZephyrBuildTarget } from 'zephyr-agent';
|
|
3
|
+
import type { ZephyrModuleFederationBuildMetadata, ZephyrModuleFederationConfig } from 'zephyr-edge-contract';
|
|
4
|
+
export interface ZephyrRolldownPluginOptions {
|
|
5
|
+
/** Zephyr build target, including the `tap-app` mini-app artifact family. */
|
|
6
|
+
target?: ZephyrBuildTarget;
|
|
7
|
+
hooks?: ZephyrBuildHooks;
|
|
8
|
+
/** Every independently published Module Federation container in the snapshot. */
|
|
9
|
+
mfConfigs?: ZephyrModuleFederationConfig[];
|
|
10
|
+
/** Build-stat metadata paired with every entry in `mfConfigs`. */
|
|
11
|
+
federation?: ZephyrModuleFederationBuildMetadata[];
|
|
12
|
+
}
|
|
13
|
+
export declare function withZephyr(options?: ZephyrRolldownPluginOptions): {
|
|
14
|
+
name: string;
|
|
15
|
+
buildStart: (inputOptions: InputOptions) => Promise<void>;
|
|
16
|
+
buildEnd: (error?: Error) => Promise<void>;
|
|
17
|
+
writeBundle: (_options: NormalizedOutputOptions, bundle: OutputBundle) => Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=zephyr-rolldown-plugin.d.mts.map
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import type { InputOptions, NormalizedOutputOptions, OutputBundle } from 'rolldown';
|
|
2
|
-
import { type ZephyrBuildHooks } from 'zephyr-agent';
|
|
3
|
-
|
|
2
|
+
import { type ZephyrBuildHooks, type ZephyrBuildTarget } from 'zephyr-agent';
|
|
3
|
+
import type { ZephyrModuleFederationBuildMetadata, ZephyrModuleFederationConfig } from 'zephyr-edge-contract';
|
|
4
|
+
export interface ZephyrRolldownPluginOptions {
|
|
5
|
+
/** Zephyr build target, including the `tap-app` mini-app artifact family. */
|
|
6
|
+
target?: ZephyrBuildTarget;
|
|
4
7
|
hooks?: ZephyrBuildHooks;
|
|
5
|
-
|
|
8
|
+
/** Every independently published Module Federation container in the snapshot. */
|
|
9
|
+
mfConfigs?: ZephyrModuleFederationConfig[];
|
|
10
|
+
/** Build-stat metadata paired with every entry in `mfConfigs`. */
|
|
11
|
+
federation?: ZephyrModuleFederationBuildMetadata[];
|
|
12
|
+
}
|
|
13
|
+
export declare function withZephyr(options?: ZephyrRolldownPluginOptions): {
|
|
6
14
|
name: string;
|
|
7
|
-
buildStart: (
|
|
15
|
+
buildStart: (inputOptions: InputOptions) => Promise<void>;
|
|
16
|
+
buildEnd: (error?: Error) => Promise<void>;
|
|
8
17
|
writeBundle: (_options: NormalizedOutputOptions, bundle: OutputBundle) => Promise<void>;
|
|
9
18
|
};
|
|
19
|
+
//# sourceMappingURL=zephyr-rolldown-plugin.d.ts.map
|
|
@@ -1,48 +1,154 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
withZephyr: ()=>withZephyr
|
|
32
|
+
});
|
|
33
|
+
const external_zephyr_agent_namespaceObject = require("zephyr-agent");
|
|
34
|
+
const external_node_process_namespaceObject = require("node:process");
|
|
35
|
+
const get_assets_map_js_namespaceObject = require("./internal/get-assets-map.js");
|
|
36
|
+
const getInputFolder = (options)=>{
|
|
37
|
+
if ('string' == typeof options.input) return options.input;
|
|
38
|
+
if (Array.isArray(options.input)) return options.input[0];
|
|
39
|
+
if ('object' == typeof options.input) return Object.values(options.input)[0];
|
|
40
|
+
return (0, external_node_process_namespaceObject.cwd)();
|
|
15
41
|
};
|
|
16
|
-
function
|
|
17
|
-
const
|
|
18
|
-
|
|
42
|
+
function getLegacyModuleFederationConfig(mfConfigs) {
|
|
43
|
+
const config = mfConfigs?.length === 1 ? mfConfigs[0] : void 0;
|
|
44
|
+
if (!config || 'string' != typeof config.name || !config.name.trim() || 'string' != typeof config.filename || !config.filename.trim()) return;
|
|
45
|
+
return config;
|
|
46
|
+
}
|
|
47
|
+
function assertTapModuleFederationMetadata(target, mfConfigs, federation) {
|
|
48
|
+
if ('tap-app' !== target) return;
|
|
49
|
+
const metadataError = (message)=>new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
50
|
+
message: `Rolldown tap-app Module Federation metadata is invalid: ${message}`
|
|
51
|
+
});
|
|
52
|
+
if (!Array.isArray(mfConfigs) || 0 === mfConfigs.length) throw metadataError('mfConfigs must be a non-empty array.');
|
|
53
|
+
if (!Array.isArray(federation) || 0 === federation.length) throw metadataError('federation must be a non-empty array.');
|
|
54
|
+
if (mfConfigs.length !== federation.length) throw metadataError('mfConfigs and federation must contain the same number of entries.');
|
|
55
|
+
const federationByName = new Map();
|
|
56
|
+
const remotes = new Set();
|
|
57
|
+
for (const entry of federation){
|
|
58
|
+
if ('string' != typeof entry.name || !entry.name.trim()) throw metadataError('every federation entry must have a non-empty name.');
|
|
59
|
+
if ('string' != typeof entry.remote || !entry.remote.trim()) throw metadataError('every federation entry must have a non-empty remote.');
|
|
60
|
+
if (federationByName.has(entry.name) || remotes.has(entry.remote)) throw metadataError('federation entries must not duplicate names or remotes.');
|
|
61
|
+
federationByName.set(entry.name, entry);
|
|
62
|
+
remotes.add(entry.remote);
|
|
63
|
+
}
|
|
64
|
+
const names = new Set();
|
|
65
|
+
const filenames = new Set();
|
|
66
|
+
for (const config of mfConfigs){
|
|
67
|
+
if ('string' != typeof config.name || !config.name.trim()) throw metadataError('every mfConfigs entry must have a non-empty name.');
|
|
68
|
+
if ('string' != typeof config.filename || !config.filename.trim()) throw metadataError('every mfConfigs entry must have a non-empty filename.');
|
|
69
|
+
if (names.has(config.name) || filenames.has(config.filename)) throw metadataError('mfConfigs entries must not duplicate names or filenames.');
|
|
70
|
+
if (federationByName.get(config.name)?.remote !== config.filename) throw metadataError(`mfConfigs entry ${JSON.stringify(config.name)} must pair with a federation remote matching ${JSON.stringify(config.filename)}.`);
|
|
71
|
+
names.add(config.name);
|
|
72
|
+
filenames.add(config.filename);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function attachFederationBuildStats(buildStats, federation) {
|
|
76
|
+
if (void 0 === federation) return buildStats;
|
|
77
|
+
const singleton = 1 === federation.length ? federation[0] : void 0;
|
|
78
|
+
return {
|
|
79
|
+
...buildStats,
|
|
80
|
+
federation,
|
|
81
|
+
remote: singleton?.remote,
|
|
82
|
+
mf_manifest: singleton?.mf_manifest,
|
|
83
|
+
library_type: singleton?.library_type,
|
|
84
|
+
exposes: singleton?.exposes,
|
|
85
|
+
shared: singleton?.shared
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function withZephyr(options = {}) {
|
|
89
|
+
if (void 0 !== options.target) (0, external_zephyr_agent_namespaceObject.assertZephyrBuildTarget)(options.target, 'withZephyr({ target })');
|
|
90
|
+
assertTapModuleFederationMetadata(options.target, options.mfConfigs, options.federation);
|
|
91
|
+
const { zephyr_engine_defer, zephyr_defer_create } = external_zephyr_agent_namespaceObject.ZephyrEngine.defer_create();
|
|
92
|
+
const hooks = options?.hooks;
|
|
93
|
+
const target = options.target;
|
|
94
|
+
const { mfConfigs, federation } = options;
|
|
95
|
+
const mfConfig = getLegacyModuleFederationConfig(mfConfigs);
|
|
19
96
|
return {
|
|
20
97
|
name: 'with-zephyr',
|
|
21
|
-
buildStart: async (
|
|
22
|
-
const path_to_execution_dir = getInputFolder(
|
|
98
|
+
buildStart: async (inputOptions)=>{
|
|
99
|
+
const path_to_execution_dir = getInputFolder(inputOptions);
|
|
23
100
|
zephyr_defer_create({
|
|
24
|
-
builder: '
|
|
101
|
+
builder: 'rolldown',
|
|
25
102
|
context: path_to_execution_dir,
|
|
103
|
+
target
|
|
26
104
|
});
|
|
27
105
|
},
|
|
28
|
-
|
|
106
|
+
buildEnd: async (error)=>{
|
|
107
|
+
if (!error) return;
|
|
29
108
|
try {
|
|
30
109
|
const zephyr_engine = await zephyr_engine_defer;
|
|
31
|
-
zephyr_engine.
|
|
32
|
-
|
|
110
|
+
if (false !== zephyr_engine.hasActiveBuild) zephyr_engine.build_failed();
|
|
111
|
+
} catch (engineError) {
|
|
112
|
+
(0, external_zephyr_agent_namespaceObject.handleGlobalError)(engineError);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
writeBundle: async (_options, bundle)=>{
|
|
116
|
+
let zephyr_engine;
|
|
117
|
+
let buildInProgress = false;
|
|
118
|
+
try {
|
|
119
|
+
zephyr_engine = await zephyr_engine_defer;
|
|
120
|
+
assertTapModuleFederationMetadata(target, mfConfigs, federation);
|
|
121
|
+
buildInProgress = true;
|
|
122
|
+
if ('tap-app' === zephyr_engine.env.target) zephyr_engine.buildProperties.baseHref = '';
|
|
123
|
+
else zephyr_engine.buildProperties.baseHref = _options.dir;
|
|
33
124
|
await zephyr_engine.start_new_build();
|
|
34
|
-
// Upload assets and finish the build
|
|
35
125
|
await zephyr_engine.upload_assets({
|
|
36
|
-
assetsMap: (0,
|
|
37
|
-
buildStats: await (0,
|
|
38
|
-
|
|
126
|
+
assetsMap: (0, get_assets_map_js_namespaceObject.getAssetsMap)(bundle),
|
|
127
|
+
buildStats: attachFederationBuildStats(await (0, external_zephyr_agent_namespaceObject.zeBuildDashData)(zephyr_engine), federation),
|
|
128
|
+
...mfConfig ? {
|
|
129
|
+
mfConfig
|
|
130
|
+
} : {},
|
|
131
|
+
...mfConfigs ? {
|
|
132
|
+
mfConfigs
|
|
133
|
+
} : {},
|
|
134
|
+
hooks
|
|
39
135
|
});
|
|
136
|
+
buildInProgress = false;
|
|
40
137
|
await zephyr_engine.build_finished();
|
|
138
|
+
} catch (error) {
|
|
139
|
+
(0, external_zephyr_agent_namespaceObject.handleGlobalError)(error);
|
|
140
|
+
} finally{
|
|
141
|
+
if (buildInProgress && zephyr_engine?.hasActiveBuild !== false) zephyr_engine?.build_failed();
|
|
41
142
|
}
|
|
42
|
-
|
|
43
|
-
(0, zephyr_agent_1.handleGlobalError)(error);
|
|
44
|
-
}
|
|
45
|
-
},
|
|
143
|
+
}
|
|
46
144
|
};
|
|
47
145
|
}
|
|
146
|
+
exports.withZephyr = __webpack_exports__.withZephyr;
|
|
147
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
148
|
+
"withZephyr"
|
|
149
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
150
|
+
Object.defineProperty(exports, '__esModule', {
|
|
151
|
+
value: true
|
|
152
|
+
});
|
|
153
|
+
|
|
48
154
|
//# sourceMappingURL=zephyr-rolldown-plugin.js.map
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { ZeErrors, ZephyrEngine, ZephyrError, assertZephyrBuildTarget, handleGlobalError, zeBuildDashData } from "zephyr-agent";
|
|
3
|
+
import { cwd } from "node:process";
|
|
4
|
+
import { getAssetsMap } from "./internal/get-assets-map.mjs";
|
|
5
|
+
const getInputFolder = (options)=>{
|
|
6
|
+
if ('string' == typeof options.input) return options.input;
|
|
7
|
+
if (Array.isArray(options.input)) return options.input[0];
|
|
8
|
+
if ('object' == typeof options.input) return Object.values(options.input)[0];
|
|
9
|
+
return cwd();
|
|
10
|
+
};
|
|
11
|
+
function getLegacyModuleFederationConfig(mfConfigs) {
|
|
12
|
+
const config = mfConfigs?.length === 1 ? mfConfigs[0] : void 0;
|
|
13
|
+
if (!config || 'string' != typeof config.name || !config.name.trim() || 'string' != typeof config.filename || !config.filename.trim()) return;
|
|
14
|
+
return config;
|
|
15
|
+
}
|
|
16
|
+
function assertTapModuleFederationMetadata(target, mfConfigs, federation) {
|
|
17
|
+
if ('tap-app' !== target) return;
|
|
18
|
+
const metadataError = (message)=>new ZephyrError(ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
19
|
+
message: `Rolldown tap-app Module Federation metadata is invalid: ${message}`
|
|
20
|
+
});
|
|
21
|
+
if (!Array.isArray(mfConfigs) || 0 === mfConfigs.length) throw metadataError('mfConfigs must be a non-empty array.');
|
|
22
|
+
if (!Array.isArray(federation) || 0 === federation.length) throw metadataError('federation must be a non-empty array.');
|
|
23
|
+
if (mfConfigs.length !== federation.length) throw metadataError('mfConfigs and federation must contain the same number of entries.');
|
|
24
|
+
const federationByName = new Map();
|
|
25
|
+
const remotes = new Set();
|
|
26
|
+
for (const entry of federation){
|
|
27
|
+
if ('string' != typeof entry.name || !entry.name.trim()) throw metadataError('every federation entry must have a non-empty name.');
|
|
28
|
+
if ('string' != typeof entry.remote || !entry.remote.trim()) throw metadataError('every federation entry must have a non-empty remote.');
|
|
29
|
+
if (federationByName.has(entry.name) || remotes.has(entry.remote)) throw metadataError('federation entries must not duplicate names or remotes.');
|
|
30
|
+
federationByName.set(entry.name, entry);
|
|
31
|
+
remotes.add(entry.remote);
|
|
32
|
+
}
|
|
33
|
+
const names = new Set();
|
|
34
|
+
const filenames = new Set();
|
|
35
|
+
for (const config of mfConfigs){
|
|
36
|
+
if ('string' != typeof config.name || !config.name.trim()) throw metadataError('every mfConfigs entry must have a non-empty name.');
|
|
37
|
+
if ('string' != typeof config.filename || !config.filename.trim()) throw metadataError('every mfConfigs entry must have a non-empty filename.');
|
|
38
|
+
if (names.has(config.name) || filenames.has(config.filename)) throw metadataError('mfConfigs entries must not duplicate names or filenames.');
|
|
39
|
+
if (federationByName.get(config.name)?.remote !== config.filename) throw metadataError(`mfConfigs entry ${JSON.stringify(config.name)} must pair with a federation remote matching ${JSON.stringify(config.filename)}.`);
|
|
40
|
+
names.add(config.name);
|
|
41
|
+
filenames.add(config.filename);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function attachFederationBuildStats(buildStats, federation) {
|
|
45
|
+
if (void 0 === federation) return buildStats;
|
|
46
|
+
const singleton = 1 === federation.length ? federation[0] : void 0;
|
|
47
|
+
return {
|
|
48
|
+
...buildStats,
|
|
49
|
+
federation,
|
|
50
|
+
remote: singleton?.remote,
|
|
51
|
+
mf_manifest: singleton?.mf_manifest,
|
|
52
|
+
library_type: singleton?.library_type,
|
|
53
|
+
exposes: singleton?.exposes,
|
|
54
|
+
shared: singleton?.shared
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function withZephyr(options = {}) {
|
|
58
|
+
if (void 0 !== options.target) assertZephyrBuildTarget(options.target, 'withZephyr({ target })');
|
|
59
|
+
assertTapModuleFederationMetadata(options.target, options.mfConfigs, options.federation);
|
|
60
|
+
const { zephyr_engine_defer, zephyr_defer_create } = ZephyrEngine.defer_create();
|
|
61
|
+
const hooks = options?.hooks;
|
|
62
|
+
const target = options.target;
|
|
63
|
+
const { mfConfigs, federation } = options;
|
|
64
|
+
const mfConfig = getLegacyModuleFederationConfig(mfConfigs);
|
|
65
|
+
return {
|
|
66
|
+
name: 'with-zephyr',
|
|
67
|
+
buildStart: async (inputOptions)=>{
|
|
68
|
+
const path_to_execution_dir = getInputFolder(inputOptions);
|
|
69
|
+
zephyr_defer_create({
|
|
70
|
+
builder: 'rolldown',
|
|
71
|
+
context: path_to_execution_dir,
|
|
72
|
+
target
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
buildEnd: async (error)=>{
|
|
76
|
+
if (!error) return;
|
|
77
|
+
try {
|
|
78
|
+
const zephyr_engine = await zephyr_engine_defer;
|
|
79
|
+
if (false !== zephyr_engine.hasActiveBuild) zephyr_engine.build_failed();
|
|
80
|
+
} catch (engineError) {
|
|
81
|
+
handleGlobalError(engineError);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
writeBundle: async (_options, bundle)=>{
|
|
85
|
+
let zephyr_engine;
|
|
86
|
+
let buildInProgress = false;
|
|
87
|
+
try {
|
|
88
|
+
zephyr_engine = await zephyr_engine_defer;
|
|
89
|
+
assertTapModuleFederationMetadata(target, mfConfigs, federation);
|
|
90
|
+
buildInProgress = true;
|
|
91
|
+
if ('tap-app' === zephyr_engine.env.target) zephyr_engine.buildProperties.baseHref = '';
|
|
92
|
+
else zephyr_engine.buildProperties.baseHref = _options.dir;
|
|
93
|
+
await zephyr_engine.start_new_build();
|
|
94
|
+
await zephyr_engine.upload_assets({
|
|
95
|
+
assetsMap: getAssetsMap(bundle),
|
|
96
|
+
buildStats: attachFederationBuildStats(await zeBuildDashData(zephyr_engine), federation),
|
|
97
|
+
...mfConfig ? {
|
|
98
|
+
mfConfig
|
|
99
|
+
} : {},
|
|
100
|
+
...mfConfigs ? {
|
|
101
|
+
mfConfigs
|
|
102
|
+
} : {},
|
|
103
|
+
hooks
|
|
104
|
+
});
|
|
105
|
+
buildInProgress = false;
|
|
106
|
+
await zephyr_engine.build_finished();
|
|
107
|
+
} catch (error) {
|
|
108
|
+
handleGlobalError(error);
|
|
109
|
+
} finally{
|
|
110
|
+
if (buildInProgress && zephyr_engine?.hasActiveBuild !== false) zephyr_engine?.build_failed();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export { withZephyr };
|
|
116
|
+
|
|
117
|
+
//# sourceMappingURL=zephyr-rolldown-plugin.mjs.map
|
package/package.json
CHANGED
|
@@ -1,38 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zephyr-rolldown-plugin",
|
|
3
|
-
"version": "0.0.0-canary.
|
|
3
|
+
"version": "0.0.0-canary.67",
|
|
4
4
|
"description": "Rolldown plugin for Zephyr",
|
|
5
|
-
"repository": {
|
|
6
|
-
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/ZephyrCloudIO/zephyr-packages.git",
|
|
8
|
-
"directory": "libs/zephyr-rolldown-plugin"
|
|
9
|
-
},
|
|
10
5
|
"license": "Apache-2.0",
|
|
11
6
|
"author": {
|
|
12
7
|
"name": "ZephyrCloudIO",
|
|
13
8
|
"url": "https://github.com/ZephyrCloudIO"
|
|
14
9
|
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/ZephyrCloudIO/zephyr-packages.git",
|
|
13
|
+
"directory": "libs/zephyr-rolldown-plugin"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE",
|
|
19
|
+
"!dist/**/*.map"
|
|
20
|
+
],
|
|
15
21
|
"type": "commonjs",
|
|
16
|
-
"main": "dist/index.js",
|
|
17
|
-
"
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"module": "./dist/index.mjs",
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"import": {
|
|
28
|
+
"types": "./dist/index.d.mts",
|
|
29
|
+
"default": "./dist/index.mjs"
|
|
30
|
+
},
|
|
31
|
+
"require": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"default": "./dist/index.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"./package.json": "./package.json",
|
|
37
|
+
"./*": "./*"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public",
|
|
41
|
+
"provenance": true
|
|
42
|
+
},
|
|
18
43
|
"dependencies": {
|
|
19
|
-
"zephyr-agent": "0.0.0-canary.
|
|
44
|
+
"zephyr-agent": "0.0.0-canary.67",
|
|
45
|
+
"zephyr-edge-contract": "0.0.0-canary.67"
|
|
20
46
|
},
|
|
21
47
|
"devDependencies": {
|
|
22
|
-
"@
|
|
23
|
-
"@
|
|
24
|
-
"rolldown": "1.
|
|
25
|
-
"
|
|
48
|
+
"@rslib/core": "0.23.2",
|
|
49
|
+
"@rstest/core": "0.11.1",
|
|
50
|
+
"rolldown": "^1.1.5",
|
|
51
|
+
"typescript": "~5.9.3"
|
|
26
52
|
},
|
|
27
53
|
"peerDependencies": {
|
|
28
54
|
"rolldown": ">=1.0.0-beta.0"
|
|
29
55
|
},
|
|
30
|
-
"publishConfig": {
|
|
31
|
-
"access": "public",
|
|
32
|
-
"provenance": true
|
|
33
|
-
},
|
|
34
56
|
"scripts": {
|
|
35
|
-
"build": "
|
|
36
|
-
"patch-version": "pnpm version"
|
|
57
|
+
"build": "rslib build",
|
|
58
|
+
"patch-version": "pnpm version",
|
|
59
|
+
"dev": "rslib build --watch",
|
|
60
|
+
"typecheck": "tsc -b",
|
|
61
|
+
"test": "rstest run"
|
|
37
62
|
}
|
|
38
63
|
}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uEAA0D;AAAjD,oHAAA,UAAU,OAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-assets-map.js","sourceRoot":"","sources":["../../../src/lib/internal/get-assets-map.ts"],"names":[],"mappings":";;AAIA,oCAEC;AAJD,+CAA8C;AAE9C,SAAgB,YAAY,CAAC,MAAoB;IAC/C,OAAO,IAAA,6BAAc,EAAC,MAAM,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,aAAa,GAAG,CAAC,KAAgC,EAAsB,EAAE;IAC7E,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,OAAO;YACV,OAAO,KAAK,CAAC,IAAI,CAAC;QACpB,KAAK,OAAO;YACV,OAAO,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ;gBACrC,CAAC,CAAC,KAAK,CAAC,MAAM;gBACd,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC7C;YACE,OAAO,KAAK,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,KAAgC,EAAU,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"zephyr-rolldown-plugin.js","sourceRoot":"","sources":["../../src/lib/zephyr-rolldown-plugin.ts"],"names":[],"mappings":";;AAiBA,gCAmCC;AAnDD,+CAKsB;AACtB,+CAAmC;AACnC,8DAAyD;AAEzD,MAAM,cAAc,GAAG,CAAC,OAAqB,EAAU,EAAE;IACvD,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAC,KAAK,CAAC;IAC5D,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC1D,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9E,OAAO,IAAA,kBAAG,GAAE,CAAC;AACf,CAAC,CAAC;AAEF,SAAgB,UAAU,CAAC,OAAsC;IAC/D,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,GAAG,2BAAY,CAAC,YAAY,EAAE,CAAC;IACjF,MAAM,KAAK,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,CAAC;IAE7B,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,UAAU,EAAE,KAAK,EAAE,OAAqB,EAAE,EAAE;YAC1C,MAAM,qBAAqB,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;YACtD,mBAAmB,CAAC;gBAClB,OAAO,EAAE,QAAQ,EAAE,gEAAgE;gBACnF,OAAO,EAAE,qBAAqB;aAC/B,CAAC,CAAC;QACL,CAAC;QACD,WAAW,EAAE,KAAK,EAAE,QAAiC,EAAE,MAAoB,EAAE,EAAE;YAC7E,IAAI,CAAC;gBACH,MAAM,aAAa,GAAG,MAAM,mBAAmB,CAAC;gBAEhD,aAAa,CAAC,eAAe,CAAC,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC;gBAEtD,oBAAoB;gBACpB,MAAM,aAAa,CAAC,eAAe,EAAE,CAAC;gBAEtC,qCAAqC;gBACrC,MAAM,aAAa,CAAC,aAAa,CAAC;oBAChC,SAAS,EAAE,IAAA,6BAAY,EAAC,MAAM,CAAC;oBAC/B,UAAU,EAAE,MAAM,IAAA,8BAAe,EAAC,aAAa,CAAC;oBAChD,KAAK;iBACN,CAAC,CAAC;gBAEH,MAAM,aAAa,CAAC,cAAc,EAAE,CAAC;YACvC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAA,gCAAiB,EAAC,KAAK,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/package.json
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "zephyr-rolldown-plugin",
|
|
3
|
-
"version": "1.1.2",
|
|
4
|
-
"description": "Rolldown plugin for Zephyr",
|
|
5
|
-
"repository": {
|
|
6
|
-
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/ZephyrCloudIO/zephyr-packages.git",
|
|
8
|
-
"directory": "libs/zephyr-rolldown-plugin"
|
|
9
|
-
},
|
|
10
|
-
"license": "Apache-2.0",
|
|
11
|
-
"author": {
|
|
12
|
-
"name": "ZephyrCloudIO",
|
|
13
|
-
"url": "https://github.com/ZephyrCloudIO"
|
|
14
|
-
},
|
|
15
|
-
"type": "commonjs",
|
|
16
|
-
"main": "dist/index.js",
|
|
17
|
-
"types": "dist/index.d.ts",
|
|
18
|
-
"scripts": {
|
|
19
|
-
"build": "nx run zephyr-rolldown-plugin:build",
|
|
20
|
-
"patch-version": "pnpm version"
|
|
21
|
-
},
|
|
22
|
-
"dependencies": {
|
|
23
|
-
"zephyr-agent": "workspace:*"
|
|
24
|
-
},
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
"@types/jest": "catalog:typescript",
|
|
27
|
-
"@typescript-eslint/eslint-plugin": "catalog:eslint",
|
|
28
|
-
"rolldown": "catalog:rolldown",
|
|
29
|
-
"ts-jest": "catalog:typescript"
|
|
30
|
-
},
|
|
31
|
-
"peerDependencies": {
|
|
32
|
-
"rolldown": ">=1.0.0-beta.0"
|
|
33
|
-
},
|
|
34
|
-
"publishConfig": {
|
|
35
|
-
"access": "public",
|
|
36
|
-
"provenance": true
|
|
37
|
-
}
|
|
38
|
-
}
|
package/eslint.config.mjs
DELETED