@framework-m/vite-plugin 0.3.3
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/LICENSE +202 -0
- package/dist/codegen.d.ts +9 -0
- package/dist/codegen.d.ts.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +201 -0
- package/dist/index.js.map +1 -0
- package/dist/mfe-config.d.ts +8 -0
- package/dist/mfe-config.d.ts.map +1 -0
- package/dist/scanner.d.ts +34 -0
- package/dist/scanner.d.ts.map +1 -0
- package/package.json +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 contributors (see contributors.json)
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DiscoveredPlugin } from './scanner';
|
|
2
|
+
/**
|
|
3
|
+
* Generate the virtual module source code for all discovered plugins.
|
|
4
|
+
*
|
|
5
|
+
* @param plugins — discovered plugins from workspace scanning
|
|
6
|
+
* @returns JavaScript/TypeScript source code string
|
|
7
|
+
*/
|
|
8
|
+
export declare function generateVirtualModule(plugins: DiscoveredPlugin[]): string;
|
|
9
|
+
//# sourceMappingURL=codegen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../src/codegen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAElD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAYzE"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* Options for the Framework M Vite plugin.
|
|
4
|
+
*/
|
|
5
|
+
export interface FrameworkMPluginOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Root directory to scan for plugins. Defaults to process.cwd().
|
|
8
|
+
*/
|
|
9
|
+
root?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Create the Framework M Vite plugin.
|
|
13
|
+
*
|
|
14
|
+
* This plugin:
|
|
15
|
+
* 1. Scans the workspace at build time for packages with "framework-m"
|
|
16
|
+
* metadata in their package.json
|
|
17
|
+
* 2. Generates a virtual module `virtual:framework-m-plugins` that imports
|
|
18
|
+
* all discovered plugin configs
|
|
19
|
+
* 3. The shell app imports this virtual module to auto-register all plugins
|
|
20
|
+
*/
|
|
21
|
+
export declare function frameworkMPlugin(options?: FrameworkMPluginOptions): Plugin;
|
|
22
|
+
export type { DiscoveredPlugin } from './scanner';
|
|
23
|
+
export { scanWorkspacePlugins } from './scanner';
|
|
24
|
+
export { generateVirtualModule } from './codegen';
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAqCnC;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,GAAE,uBAA4B,GACpC,MAAM,CAwJR;AA8ED,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import m from "node:fs";
|
|
2
|
+
import s from "node:path";
|
|
3
|
+
import { globSync as v } from "glob";
|
|
4
|
+
import b from "fast-glob";
|
|
5
|
+
async function g(n) {
|
|
6
|
+
const t = n || _(process.cwd()), o = await b("**/package.json", {
|
|
7
|
+
cwd: t,
|
|
8
|
+
ignore: ["**/node_modules/**", "**/dist/**"],
|
|
9
|
+
absolute: !0
|
|
10
|
+
}), i = [];
|
|
11
|
+
for (const e of o)
|
|
12
|
+
try {
|
|
13
|
+
const a = m.readFileSync(e, "utf-8"), r = JSON.parse(a), u = r["framework-m"];
|
|
14
|
+
if (u != null && u.plugin) {
|
|
15
|
+
const c = s.resolve(
|
|
16
|
+
s.dirname(e),
|
|
17
|
+
u.plugin
|
|
18
|
+
);
|
|
19
|
+
i.push({
|
|
20
|
+
name: r.name || s.basename(s.dirname(e)),
|
|
21
|
+
pluginConfigPath: c
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
} catch {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
return i.sort((e, a) => e.name === a.name ? e.pluginConfigPath.localeCompare(a.pluginConfigPath) : e.name.localeCompare(a.name));
|
|
28
|
+
}
|
|
29
|
+
function _(n) {
|
|
30
|
+
let t = n;
|
|
31
|
+
for (; ; ) {
|
|
32
|
+
if (m.existsSync(s.join(t, "pnpm-workspace.yaml")))
|
|
33
|
+
return t;
|
|
34
|
+
const o = s.dirname(t);
|
|
35
|
+
if (o === t) break;
|
|
36
|
+
t = o;
|
|
37
|
+
}
|
|
38
|
+
return n;
|
|
39
|
+
}
|
|
40
|
+
function x(n) {
|
|
41
|
+
if (n.length === 0)
|
|
42
|
+
return `export default [];
|
|
43
|
+
`;
|
|
44
|
+
const t = n.map((i, e) => `import plugin${e} from '${i.pluginConfigPath}';`).join(`
|
|
45
|
+
`), o = n.map((i, e) => `plugin${e}`).join(", ");
|
|
46
|
+
return `${t}
|
|
47
|
+
export default [${o}];
|
|
48
|
+
`;
|
|
49
|
+
}
|
|
50
|
+
const O = "virtual:framework-m-plugins", f = "\0virtual:framework-m-plugins";
|
|
51
|
+
function D() {
|
|
52
|
+
var o, i;
|
|
53
|
+
const n = globalThis.process, t = ((o = n == null ? void 0 : n.env) == null ? void 0 : o.FRAMEWORK_M_VITE_PLUGIN_DEBUG) ?? ((i = n == null ? void 0 : n.env) == null ? void 0 : i.FRAMEWORK_M_DEBUG);
|
|
54
|
+
return typeof t == "string" ? ["1", "true", "yes", "on"].includes(t.toLowerCase()) : !1;
|
|
55
|
+
}
|
|
56
|
+
const l = {
|
|
57
|
+
info(n) {
|
|
58
|
+
console.info(`[framework-m/vite-plugin] ${n}`);
|
|
59
|
+
},
|
|
60
|
+
debug(n) {
|
|
61
|
+
D() && console.info(`[framework-m/vite-plugin] ${n}`);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
function S(n = {}) {
|
|
65
|
+
let t = [], o = [], i = [];
|
|
66
|
+
return {
|
|
67
|
+
name: "framework-m-plugin",
|
|
68
|
+
async config(e) {
|
|
69
|
+
var c, h;
|
|
70
|
+
t = p(n.root), o = await g(n.root), i = d(o);
|
|
71
|
+
const a = (h = (c = e.build) == null ? void 0 : c.rollupOptions) == null ? void 0 : h.output, u = (Array.isArray(a) ? a : [a ?? {}]).map((k) => {
|
|
72
|
+
const w = k.manualChunks;
|
|
73
|
+
return {
|
|
74
|
+
...k,
|
|
75
|
+
manualChunks(C, M) {
|
|
76
|
+
const P = A(
|
|
77
|
+
C,
|
|
78
|
+
i
|
|
79
|
+
);
|
|
80
|
+
if (P)
|
|
81
|
+
return P;
|
|
82
|
+
if (typeof w == "function")
|
|
83
|
+
return w(C, M);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
return {
|
|
88
|
+
build: {
|
|
89
|
+
rollupOptions: {
|
|
90
|
+
output: Array.isArray(a) ? u : u[0]
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
/**
|
|
96
|
+
* Discover plugins at build start.
|
|
97
|
+
*/
|
|
98
|
+
async buildStart() {
|
|
99
|
+
const e = n.root;
|
|
100
|
+
t = p(e), o = await g(e), i = d(o);
|
|
101
|
+
const a = o.map((r) => r.name).join(", ");
|
|
102
|
+
if (l.info(
|
|
103
|
+
o.length > 0 ? `Discovered ${o.length} Framework M plugin(s): ${a}` : "Discovered 0 Framework M plugins"
|
|
104
|
+
), o.length > 0) {
|
|
105
|
+
l.debug(
|
|
106
|
+
`✓ Discovered ${o.length} Framework M plugin(s):`
|
|
107
|
+
);
|
|
108
|
+
for (const r of o)
|
|
109
|
+
l.debug(` - ${r.name}`);
|
|
110
|
+
} else
|
|
111
|
+
l.debug("ℹ No Framework M plugins found in workspace");
|
|
112
|
+
},
|
|
113
|
+
/**
|
|
114
|
+
* Resolve the virtual module ID.
|
|
115
|
+
*/
|
|
116
|
+
resolveId(e) {
|
|
117
|
+
if (e === O)
|
|
118
|
+
return f;
|
|
119
|
+
},
|
|
120
|
+
/**
|
|
121
|
+
* Load the virtual module — generate code with all plugin imports.
|
|
122
|
+
*/
|
|
123
|
+
load(e) {
|
|
124
|
+
if (e === f)
|
|
125
|
+
return x(o);
|
|
126
|
+
},
|
|
127
|
+
/**
|
|
128
|
+
* HMR: Watch plugin config files for changes.
|
|
129
|
+
*/
|
|
130
|
+
configureServer(e) {
|
|
131
|
+
for (const r of o)
|
|
132
|
+
e.watcher.add(r.pluginConfigPath);
|
|
133
|
+
for (const r of t)
|
|
134
|
+
e.watcher.add(r);
|
|
135
|
+
const a = async () => {
|
|
136
|
+
t = p(n.root), o = await g(n.root), i = d(o);
|
|
137
|
+
for (const u of o)
|
|
138
|
+
e.watcher.add(u.pluginConfigPath);
|
|
139
|
+
for (const u of t)
|
|
140
|
+
e.watcher.add(u);
|
|
141
|
+
const r = e.moduleGraph.getModuleById(
|
|
142
|
+
f
|
|
143
|
+
);
|
|
144
|
+
r && e.moduleGraph.invalidateModule(r), l.info("Plugin configuration changed, triggering reload"), e.ws.send({ type: "full-reload" });
|
|
145
|
+
};
|
|
146
|
+
e.watcher.on("change", (r) => {
|
|
147
|
+
(r.includes("plugin.config.") || t.includes(r) || o.some(
|
|
148
|
+
(c) => c.pluginConfigPath === r
|
|
149
|
+
)) && a();
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function p(n) {
|
|
155
|
+
var e;
|
|
156
|
+
const t = n ?? process.cwd(), o = v("**/package.json", {
|
|
157
|
+
cwd: t,
|
|
158
|
+
absolute: !0,
|
|
159
|
+
nodir: !0,
|
|
160
|
+
ignore: ["**/node_modules/**", "**/dist/**"]
|
|
161
|
+
}), i = [];
|
|
162
|
+
for (const a of o)
|
|
163
|
+
try {
|
|
164
|
+
const r = m.readFileSync(a, "utf8"), c = (e = JSON.parse(r)["framework-m"]) == null ? void 0 : e.plugin;
|
|
165
|
+
if (typeof c != "string")
|
|
166
|
+
continue;
|
|
167
|
+
i.push(
|
|
168
|
+
s.resolve(s.dirname(a), c)
|
|
169
|
+
);
|
|
170
|
+
} catch {
|
|
171
|
+
}
|
|
172
|
+
return i.sort((a, r) => a.localeCompare(r));
|
|
173
|
+
}
|
|
174
|
+
function y(n) {
|
|
175
|
+
return n.split("?")[0].split(s.sep).join("/");
|
|
176
|
+
}
|
|
177
|
+
function R(n) {
|
|
178
|
+
const t = s.dirname(n), o = s.basename(t);
|
|
179
|
+
return o === "src" || o === "dist" ? s.dirname(t) : t;
|
|
180
|
+
}
|
|
181
|
+
function $(n) {
|
|
182
|
+
return (n.split("/").pop() || n).replaceAll(/[^a-zA-Z0-9_-]/g, "-").toLowerCase();
|
|
183
|
+
}
|
|
184
|
+
function d(n) {
|
|
185
|
+
return n.map((t) => ({
|
|
186
|
+
prefix: y(R(t.pluginConfigPath)) + "/",
|
|
187
|
+
chunkName: $(t.name)
|
|
188
|
+
})).sort((t, o) => o.prefix.length - t.prefix.length);
|
|
189
|
+
}
|
|
190
|
+
function A(n, t) {
|
|
191
|
+
const o = y(n);
|
|
192
|
+
for (const i of t)
|
|
193
|
+
if (o.startsWith(i.prefix))
|
|
194
|
+
return i.chunkName;
|
|
195
|
+
}
|
|
196
|
+
export {
|
|
197
|
+
S as frameworkMPlugin,
|
|
198
|
+
x as generateVirtualModule,
|
|
199
|
+
g as scanWorkspacePlugins
|
|
200
|
+
};
|
|
201
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/scanner.ts","../src/codegen.ts","../src/index.ts"],"sourcesContent":["/**\n * Workspace Scanner\n *\n * Scans the monorepo workspace for packages that have \"framework-m\"\n * metadata in their package.json, indicating they are frontend plugins.\n *\n * A plugin package.json looks like:\n * ```json\n * {\n * \"name\": \"@my-company/wms\",\n * \"framework-m\": {\n * \"plugin\": \"./src/plugin.config.ts\",\n * \"type\": \"frontend-module\"\n * }\n * }\n * ```\n */\n\nimport fg from \"fast-glob\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\n/**\n * Represents a discovered Framework M plugin in the workspace.\n */\nexport interface DiscoveredPlugin {\n /** Package name from package.json */\n name: string;\n /** Absolute path to the plugin config file */\n pluginConfigPath: string;\n}\n\n/**\n * Scan the workspace for packages with \"framework-m\" plugin metadata.\n *\n * @param root — workspace root directory to scan\n * @returns Array of discovered plugins with their config paths\n */\nexport async function scanWorkspacePlugins(\n root?: string,\n): Promise<DiscoveredPlugin[]> {\n // Find workspace root by looking for pnpm-workspace.yaml\n const scanRoot = root || findWorkspaceRoot(process.cwd());\n\n // Find all package.json files, excluding node_modules and dist\n const packageJsonPaths = await fg(\"**/package.json\", {\n cwd: scanRoot,\n ignore: [\"**/node_modules/**\", \"**/dist/**\"],\n absolute: true,\n });\n\n const plugins: DiscoveredPlugin[] = [];\n\n for (const pkgPath of packageJsonPaths) {\n try {\n const content = fs.readFileSync(pkgPath, \"utf-8\");\n const pkg = JSON.parse(content) as Record<string, unknown>;\n\n // Check for framework-m plugin metadata\n const frameworkM = pkg[\"framework-m\"] as\n | { plugin?: string; type?: string }\n | undefined;\n\n if (frameworkM?.plugin) {\n const pluginConfigPath = path.resolve(\n path.dirname(pkgPath),\n frameworkM.plugin,\n );\n\n plugins.push({\n name: (pkg.name as string) || path.basename(path.dirname(pkgPath)),\n pluginConfigPath,\n });\n }\n } catch {\n // Skip unreadable or malformed package.json files\n continue;\n }\n }\n\n return plugins.sort((a, b) => {\n if (a.name === b.name) {\n return a.pluginConfigPath.localeCompare(b.pluginConfigPath);\n }\n return a.name.localeCompare(b.name);\n });\n}\n\n/**\n * Walk up from startDir to find the workspace root (directory containing pnpm-workspace.yaml).\n * Falls back to startDir if not found.\n */\nfunction findWorkspaceRoot(startDir: string): string {\n let dir = startDir;\n while (true) {\n if (fs.existsSync(path.join(dir, \"pnpm-workspace.yaml\"))) {\n return dir;\n }\n const parent = path.dirname(dir);\n if (parent === dir) break; // reached filesystem root\n dir = parent;\n }\n return startDir; // fallback\n}\n","/**\n * Virtual Module Code Generator\n *\n * Generates the code for the `virtual:framework-m-plugins` virtual module.\n * This module imports all discovered plugin configs and exports them as an array.\n *\n * Generated output looks like:\n * ```js\n * import plugin0 from '/workspace/apps/wms/frontend/src/plugin.config.ts';\n * import plugin1 from '/workspace/apps/hr/frontend/src/plugin.config.ts';\n * export default [plugin0, plugin1];\n * ```\n */\n\nimport type { DiscoveredPlugin } from \"./scanner\";\n\n/**\n * Generate the virtual module source code for all discovered plugins.\n *\n * @param plugins — discovered plugins from workspace scanning\n * @returns JavaScript/TypeScript source code string\n */\nexport function generateVirtualModule(plugins: DiscoveredPlugin[]): string {\n if (plugins.length === 0) {\n return \"export default [];\\n\";\n }\n\n const imports = plugins\n .map((p, i) => `import plugin${i} from '${p.pluginConfigPath}';`)\n .join(\"\\n\");\n\n const exportNames = plugins.map((_, i) => `plugin${i}`).join(\", \");\n\n return `${imports}\\nexport default [${exportNames}];\\n`;\n}\n","/**\n * @framework-m/vite-plugin\n *\n * Vite plugin for Framework M plugin auto-discovery and bundling.\n *\n * Scans the workspace for packages with \"framework-m\" metadata in their\n * package.json and generates a virtual module that imports all plugin\n * configs. The shell app can then import this virtual module to\n * bootstrap all plugins automatically.\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { frameworkMPlugin } from \"@framework-m/vite-plugin\";\n *\n * export default defineConfig({\n * plugins: [frameworkMPlugin()],\n * });\n * ```\n *\n * @example\n * ```ts\n * // In shell app:\n * // @ts-ignore - Virtual module generated by Vite plugin\n * import discoveredPlugins from \"virtual:framework-m-plugins\";\n *\n * for (const plugin of discoveredPlugins) {\n * await registry.register(plugin);\n * }\n * ```\n */\n\nimport type { Plugin } from \"vite\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { globSync } from \"glob\";\nimport { scanWorkspacePlugins } from \"./scanner\";\nimport { generateVirtualModule } from \"./codegen\";\nimport type { DiscoveredPlugin } from \"./scanner\";\n\nconst VIRTUAL_MODULE_ID = \"virtual:framework-m-plugins\";\nconst RESOLVED_VIRTUAL_MODULE_ID = \"\\0virtual:framework-m-plugins\";\n\nfunction isDebugEnabled(): boolean {\n const processRef = (\n globalThis as { process?: { env?: Record<string, string | undefined> } }\n ).process;\n const envFlag =\n processRef?.env?.FRAMEWORK_M_VITE_PLUGIN_DEBUG ??\n processRef?.env?.FRAMEWORK_M_DEBUG;\n\n if (typeof envFlag === \"string\") {\n return [\"1\", \"true\", \"yes\", \"on\"].includes(envFlag.toLowerCase());\n }\n\n return false;\n}\n\nconst pluginLogger = {\n info(message: string): void {\n console.info(`[framework-m/vite-plugin] ${message}`);\n },\n debug(message: string): void {\n if (isDebugEnabled()) {\n console.info(`[framework-m/vite-plugin] ${message}`);\n }\n },\n};\n\n/**\n * Options for the Framework M Vite plugin.\n */\nexport interface FrameworkMPluginOptions {\n /**\n * Root directory to scan for plugins. Defaults to process.cwd().\n */\n root?: string;\n}\n\n/**\n * Create the Framework M Vite plugin.\n *\n * This plugin:\n * 1. Scans the workspace at build time for packages with \"framework-m\"\n * metadata in their package.json\n * 2. Generates a virtual module `virtual:framework-m-plugins` that imports\n * all discovered plugin configs\n * 3. The shell app imports this virtual module to auto-register all plugins\n */\nexport function frameworkMPlugin(\n options: FrameworkMPluginOptions = {},\n): Plugin {\n let pluginPaths: string[] = [];\n let discoveredPlugins: DiscoveredPlugin[] = [];\n let pluginChunkMatchers: Array<{ prefix: string; chunkName: string }> = [];\n\n return {\n name: \"framework-m-plugin\",\n\n async config(userConfig) {\n pluginPaths = discoverPluginConfigPaths(options.root);\n discoveredPlugins = await scanWorkspacePlugins(options.root);\n pluginChunkMatchers = createPluginChunkMatchers(discoveredPlugins);\n\n const existingOutput = userConfig.build?.rollupOptions?.output;\n const existingOutputs = Array.isArray(existingOutput)\n ? existingOutput\n : [existingOutput ?? {}];\n\n const mergedOutputs = existingOutputs.map(output => {\n const existingManualChunks = output.manualChunks;\n\n return {\n ...output,\n manualChunks(id: string, meta: unknown) {\n const pluginChunk = findPluginChunkForModule(\n id,\n pluginChunkMatchers,\n );\n if (pluginChunk) {\n return pluginChunk;\n }\n\n if (typeof existingManualChunks === \"function\") {\n return (\n existingManualChunks as (\n id: string,\n meta: unknown,\n ) => string | undefined\n )(id, meta);\n }\n\n return undefined;\n },\n };\n });\n\n return {\n build: {\n rollupOptions: {\n output: Array.isArray(existingOutput)\n ? mergedOutputs\n : mergedOutputs[0],\n },\n },\n };\n },\n\n /**\n * Discover plugins at build start.\n */\n async buildStart() {\n const root = options.root;\n pluginPaths = discoverPluginConfigPaths(root);\n discoveredPlugins = await scanWorkspacePlugins(root);\n pluginChunkMatchers = createPluginChunkMatchers(discoveredPlugins);\n\n const pluginNames = discoveredPlugins.map(p => p.name).join(\", \");\n pluginLogger.info(\n discoveredPlugins.length > 0\n ? `Discovered ${discoveredPlugins.length} Framework M plugin(s): ${pluginNames}`\n : \"Discovered 0 Framework M plugins\",\n );\n\n if (discoveredPlugins.length > 0) {\n pluginLogger.debug(\n `✓ Discovered ${discoveredPlugins.length} Framework M plugin(s):`,\n );\n for (const p of discoveredPlugins) {\n pluginLogger.debug(` - ${p.name}`);\n }\n } else {\n pluginLogger.debug(\"ℹ No Framework M plugins found in workspace\");\n }\n },\n\n /**\n * Resolve the virtual module ID.\n */\n resolveId(id: string) {\n if (id === VIRTUAL_MODULE_ID) {\n return RESOLVED_VIRTUAL_MODULE_ID;\n }\n return undefined;\n },\n\n /**\n * Load the virtual module — generate code with all plugin imports.\n */\n load(id: string) {\n if (id === RESOLVED_VIRTUAL_MODULE_ID) {\n return generateVirtualModule(discoveredPlugins);\n }\n return undefined;\n },\n\n /**\n * HMR: Watch plugin config files for changes.\n */\n configureServer(server) {\n // Watch all discovered plugin config files\n for (const plugin of discoveredPlugins) {\n server.watcher.add(plugin.pluginConfigPath);\n }\n for (const pluginConfigPath of pluginPaths) {\n server.watcher.add(pluginConfigPath);\n }\n\n const refreshPlugins = async () => {\n pluginPaths = discoverPluginConfigPaths(options.root);\n discoveredPlugins = await scanWorkspacePlugins(options.root);\n pluginChunkMatchers = createPluginChunkMatchers(discoveredPlugins);\n for (const plugin of discoveredPlugins) {\n server.watcher.add(plugin.pluginConfigPath);\n }\n for (const pluginConfigPath of pluginPaths) {\n server.watcher.add(pluginConfigPath);\n }\n\n const virtualModule = server.moduleGraph.getModuleById(\n RESOLVED_VIRTUAL_MODULE_ID,\n );\n if (virtualModule) {\n server.moduleGraph.invalidateModule(virtualModule);\n }\n\n pluginLogger.info(\"Plugin configuration changed, triggering reload\");\n server.ws.send({ type: \"full-reload\" });\n };\n\n server.watcher.on(\"change\", filePath => {\n const shouldRefresh =\n filePath.includes(\"plugin.config.\") ||\n pluginPaths.includes(filePath) ||\n discoveredPlugins.some(\n plugin => plugin.pluginConfigPath === filePath,\n );\n if (shouldRefresh) {\n void refreshPlugins();\n }\n });\n },\n };\n}\n\nfunction discoverPluginConfigPaths(root?: string): string[] {\n const workspaceRoot = root ?? process.cwd();\n const packageJsonPaths = globSync(\"**/package.json\", {\n cwd: workspaceRoot,\n absolute: true,\n nodir: true,\n ignore: [\"**/node_modules/**\", \"**/dist/**\"],\n });\n\n const pluginPaths: string[] = [];\n for (const packageJsonPath of packageJsonPaths) {\n try {\n const packageRaw = fs.readFileSync(packageJsonPath, \"utf8\");\n const packageJson = JSON.parse(packageRaw) as {\n \"framework-m\"?: { plugin?: unknown };\n };\n\n const pluginConfig = packageJson[\"framework-m\"]?.plugin;\n if (typeof pluginConfig !== \"string\") {\n continue;\n }\n\n pluginPaths.push(\n path.resolve(path.dirname(packageJsonPath), pluginConfig),\n );\n } catch {\n // Ignore invalid package.json files and continue scanning.\n }\n }\n\n return pluginPaths.sort((a, b) => a.localeCompare(b));\n}\n\nfunction normalizeModuleId(id: string): string {\n return id.split(\"?\")[0].split(path.sep).join(\"/\");\n}\n\nfunction inferPluginRoot(pluginConfigPath: string): string {\n const configDir = path.dirname(pluginConfigPath);\n const base = path.basename(configDir);\n if (base === \"src\" || base === \"dist\") {\n return path.dirname(configDir);\n }\n return configDir;\n}\n\nfunction toChunkName(pluginName: string): string {\n const tail = pluginName.split(\"/\").pop() || pluginName;\n return tail.replaceAll(/[^a-zA-Z0-9_-]/g, \"-\").toLowerCase();\n}\n\nfunction createPluginChunkMatchers(\n plugins: DiscoveredPlugin[],\n): Array<{ prefix: string; chunkName: string }> {\n return plugins\n .map(plugin => ({\n prefix: normalizeModuleId(inferPluginRoot(plugin.pluginConfigPath)) + \"/\",\n chunkName: toChunkName(plugin.name),\n }))\n .sort((a, b) => b.prefix.length - a.prefix.length);\n}\n\nfunction findPluginChunkForModule(\n id: string,\n matchers: Array<{ prefix: string; chunkName: string }>,\n): string | undefined {\n const normalizedId = normalizeModuleId(id);\n for (const matcher of matchers) {\n if (normalizedId.startsWith(matcher.prefix)) {\n return matcher.chunkName;\n }\n }\n return undefined;\n}\n\n// Re-export types and utilities\nexport type { DiscoveredPlugin } from \"./scanner\";\nexport { scanWorkspacePlugins } from \"./scanner\";\nexport { generateVirtualModule } from \"./codegen\";\n"],"names":["scanWorkspacePlugins","root","scanRoot","findWorkspaceRoot","packageJsonPaths","fg","plugins","pkgPath","content","fs","pkg","frameworkM","pluginConfigPath","path","a","b","startDir","dir","parent","generateVirtualModule","imports","p","i","exportNames","_","VIRTUAL_MODULE_ID","RESOLVED_VIRTUAL_MODULE_ID","isDebugEnabled","processRef","envFlag","_a","_b","pluginLogger","message","frameworkMPlugin","options","pluginPaths","discoveredPlugins","pluginChunkMatchers","userConfig","discoverPluginConfigPaths","createPluginChunkMatchers","existingOutput","mergedOutputs","output","existingManualChunks","id","meta","pluginChunk","findPluginChunkForModule","pluginNames","server","plugin","refreshPlugins","virtualModule","filePath","workspaceRoot","globSync","packageJsonPath","packageRaw","pluginConfig","normalizeModuleId","inferPluginRoot","configDir","base","toChunkName","pluginName","matchers","normalizedId","matcher"],"mappings":";;;;AAsCA,eAAsBA,EACpBC,GAC6B;AAE7B,QAAMC,IAAWD,KAAQE,EAAkB,QAAQ,KAAK,GAGlDC,IAAmB,MAAMC,EAAG,mBAAmB;AAAA,IACnD,KAAKH;AAAA,IACL,QAAQ,CAAC,sBAAsB,YAAY;AAAA,IAC3C,UAAU;AAAA,EAAA,CACX,GAEKI,IAA8B,CAAA;AAEpC,aAAWC,KAAWH;AACpB,QAAI;AACF,YAAMI,IAAUC,EAAG,aAAaF,GAAS,OAAO,GAC1CG,IAAM,KAAK,MAAMF,CAAO,GAGxBG,IAAaD,EAAI,aAAa;AAIpC,UAAIC,KAAA,QAAAA,EAAY,QAAQ;AACtB,cAAMC,IAAmBC,EAAK;AAAA,UAC5BA,EAAK,QAAQN,CAAO;AAAA,UACpBI,EAAW;AAAA,QAAA;AAGb,QAAAL,EAAQ,KAAK;AA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QkD,CAAS,IAExBA;AACT;AAEA,SAASE,EAAYC,GAA4B;AAE/C,UADaA,EAAW,MAAM,GAAG,EAAE,SAASA,GAChC,WAAW,mBAAmB,GAAG,EAAE,YAAA;AACjD;AAEA,SAASzB,EACPnC,GAC8C;AAC9C,SAAOA,EACJ,IAAI,CAAA8C,OAAW;AAAA,IACd,QAAQS,EAAkBC,EAAgBV,EAAO,gBAAgB,CAAC,IAAI;AAAA,IACtE,WAAWa,EAAYb,EAAO,IAAI;AAAA,EAAA,EAClC,EACD,KAAK,CAACtC,GAAGC,MAAMA,EAAE,OAAO,SAASD,EAAE,OAAO,MAAM;AACrD;AAEA,SAASmC,EACPH,GACAqB,GACoB;AACpB,QAAMC,IAAeP,EAAkBf,CAAE;AACzC,aAAWuB,KAAWF;AACpB,QAAIC,EAAa,WAAWC,EAAQ,MAAM;AACxC,aAAOA,EAAQ;AAIrB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mfe-config.d.ts","sourceRoot":"","sources":["../src/mfe-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAGvC,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,UAAU,GAAG,UAAU,CAkBjE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace Scanner
|
|
3
|
+
*
|
|
4
|
+
* Scans the monorepo workspace for packages that have "framework-m"
|
|
5
|
+
* metadata in their package.json, indicating they are frontend plugins.
|
|
6
|
+
*
|
|
7
|
+
* A plugin package.json looks like:
|
|
8
|
+
* ```json
|
|
9
|
+
* {
|
|
10
|
+
* "name": "@my-company/wms",
|
|
11
|
+
* "framework-m": {
|
|
12
|
+
* "plugin": "./src/plugin.config.ts",
|
|
13
|
+
* "type": "frontend-module"
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Represents a discovered Framework M plugin in the workspace.
|
|
20
|
+
*/
|
|
21
|
+
export interface DiscoveredPlugin {
|
|
22
|
+
/** Package name from package.json */
|
|
23
|
+
name: string;
|
|
24
|
+
/** Absolute path to the plugin config file */
|
|
25
|
+
pluginConfigPath: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Scan the workspace for packages with "framework-m" plugin metadata.
|
|
29
|
+
*
|
|
30
|
+
* @param root — workspace root directory to scan
|
|
31
|
+
* @returns Array of discovered plugins with their config paths
|
|
32
|
+
*/
|
|
33
|
+
export declare function scanWorkspacePlugins(root?: string): Promise<DiscoveredPlugin[]>;
|
|
34
|
+
//# sourceMappingURL=scanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,gBAAgB,EAAE,CAAC,CA8C7B"}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@framework-m/vite-plugin",
|
|
3
|
+
"version": "0.3.3",
|
|
4
|
+
"description": "Vite plugin for Framework M plugin auto-discovery and bundling",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"keywords": [
|
|
20
|
+
"framework-m",
|
|
21
|
+
"vite-plugin",
|
|
22
|
+
"plugin-discovery",
|
|
23
|
+
"multi-app"
|
|
24
|
+
],
|
|
25
|
+
"author": "Framework M Team",
|
|
26
|
+
"license": "Apache-2.0",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "https://gitlab.com/castlecraft/framework-m.git",
|
|
30
|
+
"directory": "libs/framework-m-vite-plugin"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"vite": "^5.0.0 || ^6.0.0"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@framework-m/plugin-sdk": "^0.1.0",
|
|
37
|
+
"@originjs/vite-plugin-federation": "^1.4.1",
|
|
38
|
+
"fast-glob": "^3.3.3",
|
|
39
|
+
"glob": "^10.0.0",
|
|
40
|
+
"vite": "^6.0.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/node": "^22.19.15",
|
|
44
|
+
"typescript": "^5.9.3",
|
|
45
|
+
"vite": "^6.4.1",
|
|
46
|
+
"vite-plugin-dts": "^4.5.1",
|
|
47
|
+
"vitest": "^4.1.0"
|
|
48
|
+
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsc && vite build",
|
|
54
|
+
"dev": "vite build --watch",
|
|
55
|
+
"type-check": "tsc --noEmit",
|
|
56
|
+
"test": "vitest run",
|
|
57
|
+
"test:watch": "vitest",
|
|
58
|
+
"test:coverage": "vitest run --coverage"
|
|
59
|
+
}
|
|
60
|
+
}
|