@mbsks/rspfx-manifest-generator 0.0.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 +21 -0
- package/README.md +35 -0
- package/dist/component-manifests.d.ts +3 -0
- package/dist/component-manifests.d.ts.map +1 -0
- package/dist/component-manifests.js +127 -0
- package/dist/component-manifests.js.map +1 -0
- package/dist/data/component-ids.d.ts +7 -0
- package/dist/data/component-ids.d.ts.map +1 -0
- package/dist/data/component-ids.js +19 -0
- package/dist/data/component-ids.js.map +1 -0
- package/dist/errors.d.ts +2 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +2 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/manifests-js.d.ts +2 -0
- package/dist/manifests-js.d.ts.map +1 -0
- package/dist/manifests-js.js +81 -0
- package/dist/manifests-js.js.map +1 -0
- package/dist/rewrite.d.ts +11 -0
- package/dist/rewrite.d.ts.map +1 -0
- package/dist/rewrite.js +46 -0
- package/dist/rewrite.js.map +1 -0
- package/dist/sp-dependencies.d.ts +7 -0
- package/dist/sp-dependencies.d.ts.map +1 -0
- package/dist/sp-dependencies.js +64 -0
- package/dist/sp-dependencies.js.map +1 -0
- package/dist/types.d.ts +33 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +33 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 RSPFX contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# @mbsks/rspfx-manifest-generator
|
|
2
|
+
|
|
3
|
+
Manifest generation for [RSPFX](https://github.com/master8848/rspfx) — an SPFx-compatible build toolchain powered by Rspack.
|
|
4
|
+
|
|
5
|
+
Generates SPFx-compatible component manifests, the AMD `manifests.js` loader script, and detects `@microsoft/sp-*` dependencies — byte-compatible with official SPFx output formats.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm i @mbsks/rspfx-manifest-generator
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { generateComponentManifests, generateManifestsJs, findSpDependencies } from '@mbsks/rspfx-manifest-generator';
|
|
17
|
+
import type { ComponentManifest, SpDependency } from '@mbsks/rspfx-manifest-generator';
|
|
18
|
+
|
|
19
|
+
const manifests: ComponentManifest[] = generateComponentManifests(project, buildResult);
|
|
20
|
+
const deps: SpDependency[] = findSpDependencies(manifestIds);
|
|
21
|
+
const loader = generateManifestsJs(manifests, { deployPath: 'dist' });
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## API
|
|
25
|
+
|
|
26
|
+
- `generateComponentManifests(project, buildResult)` — web part manifests (`*.manifest.json`)
|
|
27
|
+
- `generateManifestsJs(manifests, opts)` — AMD `manifests.js` loader script
|
|
28
|
+
- `findSpDependencies(manifestIds)` — `@microsoft/sp-*` dependency mapping
|
|
29
|
+
- `ComponentManifest`, `ManifestContext`, `SpDependency` — types
|
|
30
|
+
|
|
31
|
+
## Links
|
|
32
|
+
|
|
33
|
+
- [RSPFX documentation](https://github.com/master8848/rspfx/tree/main/docs)
|
|
34
|
+
- [Format ground truth](https://github.com/master8848/rspfx/blob/main/reference/FORMATS.md)
|
|
35
|
+
- License: MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-manifests.d.ts","sourceRoot":"","sources":["../src/component-manifests.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAqCrE,wBAAsB,0BAA0B,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAkGnG"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { RspfxError } from './errors.js';
|
|
4
|
+
import { SP_COMPONENT_IDS } from './data/component-ids.js';
|
|
5
|
+
import { findSpDependencies } from './sp-dependencies.js';
|
|
6
|
+
function stripPreReleaseVersion(version) {
|
|
7
|
+
const index = version.indexOf('-');
|
|
8
|
+
return index >= 0 ? version.slice(0, index) : version;
|
|
9
|
+
}
|
|
10
|
+
function findNonSpExternalManifest(projectRoot, pkgName) {
|
|
11
|
+
const distDir = path.join(projectRoot, 'node_modules', pkgName, 'dist');
|
|
12
|
+
let files;
|
|
13
|
+
try {
|
|
14
|
+
files = fs.readdirSync(distDir);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
const manifestFile = files
|
|
20
|
+
.filter((file) => file.endsWith('.manifest.json') && !file.startsWith('.'))
|
|
21
|
+
.sort()[0];
|
|
22
|
+
if (!manifestFile) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const manifest = JSON.parse(fs.readFileSync(path.join(distDir, manifestFile), 'utf8'));
|
|
27
|
+
if (typeof manifest.id === 'string' && typeof manifest.version === 'string') {
|
|
28
|
+
return { id: manifest.id, version: manifest.version };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
export async function generateComponentManifests(ctx) {
|
|
37
|
+
const webpartsDir = path.join(ctx.projectRoot, ctx.webpartsDir ?? 'src/webparts');
|
|
38
|
+
let webpartDirs;
|
|
39
|
+
try {
|
|
40
|
+
webpartDirs = fs.readdirSync(webpartsDir, { withFileTypes: true });
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
const spDependencies = findSpDependencies(ctx.projectRoot);
|
|
46
|
+
const manifests = [];
|
|
47
|
+
for (const dirEntry of webpartDirs) {
|
|
48
|
+
if (!dirEntry.isDirectory() || dirEntry.name.startsWith('.')) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const dirPath = path.join(webpartsDir, dirEntry.name);
|
|
52
|
+
const manifestFiles = fs
|
|
53
|
+
.readdirSync(dirPath)
|
|
54
|
+
.filter((file) => file.endsWith('.manifest.json') && !file.startsWith('.'));
|
|
55
|
+
if (manifestFiles.length === 0) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (manifestFiles.length > 1) {
|
|
59
|
+
throw new RspfxError('MULTIPLE_MANIFESTS', `Expected exactly one manifest per web part folder but found ${manifestFiles.length} in ${dirPath}: ${manifestFiles.join(', ')}`);
|
|
60
|
+
}
|
|
61
|
+
const source = JSON.parse(fs.readFileSync(path.join(dirPath, manifestFiles[0]), 'utf8'));
|
|
62
|
+
delete source.$schema;
|
|
63
|
+
if (source.version === '*') {
|
|
64
|
+
source.version = stripPreReleaseVersion(ctx.packageVersion);
|
|
65
|
+
}
|
|
66
|
+
const manifestId = typeof source.id === 'string' ? source.id : undefined;
|
|
67
|
+
const entryModuleId = (manifestId !== undefined ? ctx.entryModuleIds?.[manifestId] : undefined) ?? dirEntry.name;
|
|
68
|
+
const scriptResources = {
|
|
69
|
+
[entryModuleId]: {
|
|
70
|
+
type: 'path',
|
|
71
|
+
path: ctx.bundleFiles.get(entryModuleId) ?? `${entryModuleId}.js`
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const localizedNames = new Set((ctx.localizedResources ?? []).map((resource) => resource.name));
|
|
75
|
+
const externalNames = [...ctx.externals]
|
|
76
|
+
.filter((name) => name !== entryModuleId && !localizedNames.has(name))
|
|
77
|
+
.sort();
|
|
78
|
+
for (const externalName of externalNames) {
|
|
79
|
+
const spDependency = spDependencies.get(externalName);
|
|
80
|
+
if (spDependency) {
|
|
81
|
+
scriptResources[externalName] = {
|
|
82
|
+
type: 'component',
|
|
83
|
+
id: spDependency.id,
|
|
84
|
+
version: spDependency.version
|
|
85
|
+
};
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const nonSpDependency = findNonSpExternalManifest(ctx.projectRoot, externalName);
|
|
89
|
+
if (!nonSpDependency) {
|
|
90
|
+
const fallback = SP_COMPONENT_IDS[externalName];
|
|
91
|
+
if (fallback) {
|
|
92
|
+
scriptResources[externalName] = {
|
|
93
|
+
type: 'component',
|
|
94
|
+
id: fallback.id,
|
|
95
|
+
version: fallback.version
|
|
96
|
+
};
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
throw new RspfxError('UNRESOLVED_EXTERNAL', `External '${externalName}' could not be resolved to a component manifest (expected a .manifest.json under node_modules/${externalName}/dist)`);
|
|
100
|
+
}
|
|
101
|
+
scriptResources[externalName] = {
|
|
102
|
+
type: 'component',
|
|
103
|
+
id: nonSpDependency.id,
|
|
104
|
+
version: nonSpDependency.version
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
for (const resource of ctx.localizedResources ?? []) {
|
|
108
|
+
const paths = {};
|
|
109
|
+
const defaultLocale = resource.locales.find((locale) => locale === 'en-us');
|
|
110
|
+
if (defaultLocale !== undefined) {
|
|
111
|
+
paths['default'] = { path: `${resource.name}_${defaultLocale}.js`, integrity: '' };
|
|
112
|
+
}
|
|
113
|
+
for (const locale of resource.locales) {
|
|
114
|
+
paths[locale] = { path: `${resource.name}_${locale}.js`, integrity: '' };
|
|
115
|
+
}
|
|
116
|
+
scriptResources[resource.name] = { type: 'localizedPath', paths };
|
|
117
|
+
}
|
|
118
|
+
source.loaderConfig = {
|
|
119
|
+
internalModuleBaseUrls: ctx.production ? ctx.baseUrls.release : [ctx.baseUrls.debug],
|
|
120
|
+
entryModuleId,
|
|
121
|
+
scriptResources
|
|
122
|
+
};
|
|
123
|
+
manifests.push(source);
|
|
124
|
+
}
|
|
125
|
+
return manifests;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=component-manifests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-manifests.js","sourceRoot":"","sources":["../src/component-manifests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,SAAS,sBAAsB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= {
|
|
2
|
+
'@microsoft/sp-core-library': { id: '7263c7d0-1d6a-45ec-8d85-d4d1d234171b', version: '1.23.2' },
|
|
3
|
+
'@microsoft/sp-loader': { id: '1c6c9123-7aac-41f3-a376-3caea41ed83f', version: '1.23.2' },
|
|
4
|
+
'@microsoft/sp-webpart-base': {
|
|
5
|
+
id: '974a7777-0990-4136-8fa6-95d80114c2e0',
|
|
6
|
+
version: '1.23.2',
|
|
7
|
+
preloadComponents: ['f9e737b7-f0df-4597-ba8c-3060f82380db']
|
|
8
|
+
},
|
|
9
|
+
'@microsoft/sp-component-base': { id: '467dc675-7cc5-4709-8aac-78e3b71bd2f6', version: '1.23.2' },
|
|
10
|
+
'@microsoft/sp-property-pane': { id: 'f9e737b7-f0df-4597-ba8c-3060f82380db', version: '1.23.2' },
|
|
11
|
+
'@microsoft/sp-page-context': { id: '1c4541f7-5c31-41aa-9fa8-fbc9dc14c0a8', version: '1.23.2' },
|
|
12
|
+
'@microsoft/sp-http': { id: 'c07208f0-ea3b-4c1a-9965-ac1b825211a6', version: '1.23.2' },
|
|
13
|
+
'@microsoft/sp-http-base': { id: '8496636c-2300-4915-abef-20de64c98d8b', version: '1.23.2' },
|
|
14
|
+
'@microsoft/sp-diagnostics': { id: '78359e4b-07c2-43c6-8d0b-d060b4d577e8', version: '1.23.2' },
|
|
15
|
+
'@microsoft/sp-dynamic-data': { id: 'e40f8203-b39d-425a-a957-714852e33b79', version: '1.23.2' },
|
|
16
|
+
'@microsoft/load-themed-styles': { id: '229b8d08-79f3-438b-8c21-4613fc877abd', version: '0.1.2' },
|
|
17
|
+
tslib: { id: '01c4df03-e775-48cb-aa14-171ee5199a15', version: '2.3.1' }
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=component-ids.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-ids.js","sourceRoot":"","sources":["../../src/data/component-ids.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,gBAAgB,G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"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { generateComponentManifests } from './component-manifests.js';
|
|
2
|
+
export type { ComponentManifest, LocalizedResourceEntry, ManifestContext } from './types.js';
|
|
3
|
+
export { RspfxError } from './errors.js';
|
|
4
|
+
export { generateManifestsJs } from './manifests-js.js';
|
|
5
|
+
export { findSpDependencies } from './sp-dependencies.js';
|
|
6
|
+
export type { SpDependency } from './sp-dependencies.js';
|
|
7
|
+
export { collectDebugManifests, ensureTrailingSlash, joinUrlSegments, rewriteSpManifestForDebug } from './rewrite.js';
|
|
8
|
+
export type { CollectDebugManifestsOptions } from './rewrite.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,YAAY,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,eAAe,EACf,yBAAyB,EAC1B,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { generateComponentManifests } from './component-manifests.js';
|
|
2
|
+
export { RspfxError } from './errors.js';
|
|
3
|
+
export { generateManifestsJs } from './manifests-js.js';
|
|
4
|
+
export { findSpDependencies } from './sp-dependencies.js';
|
|
5
|
+
export { collectDebugManifests, ensureTrailingSlash, joinUrlSegments, rewriteSpManifestForDebug } from './rewrite.js';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAEtE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,eAAe,EACf,yBAAyB,EAC1B,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifests-js.d.ts","sourceRoot":"","sources":["../src/manifests-js.ts"],"names":[],"mappings":"AAAA,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,OAAO,EAAE,EACpB,QAAQ,CAAC,EAAE,OAAO,GACjB,OAAO,CAAC,MAAM,CAAC,CA+EjB"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export async function generateManifestsJs(manifests, metadata) {
|
|
2
|
+
const manifestsJson = JSON.stringify(manifests);
|
|
3
|
+
const metadataJson = metadata === undefined ? 'undefined' : JSON.stringify(metadata);
|
|
4
|
+
return `(() => {
|
|
5
|
+
const MANIFESTS_ARRAY = ${manifestsJson};
|
|
6
|
+
let publicPath = '';
|
|
7
|
+
try {
|
|
8
|
+
const scripts = document.getElementsByTagName('script');
|
|
9
|
+
const currentScript = document.currentScript || (scripts.length ? scripts[scripts.length - 1] : undefined);
|
|
10
|
+
if (currentScript && currentScript.src) {
|
|
11
|
+
const url = new URL(currentScript.src, window.location.href);
|
|
12
|
+
let base = url.href;
|
|
13
|
+
if (!base.endsWith('/')) {
|
|
14
|
+
const slashIndex = base.lastIndexOf('/');
|
|
15
|
+
if (slashIndex >= 0) {
|
|
16
|
+
base = base.slice(0, slashIndex + 1);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
publicPath = base;
|
|
20
|
+
}
|
|
21
|
+
} catch (error) {
|
|
22
|
+
console.error('Unable to determine the base URL of the debug manifests file.', error);
|
|
23
|
+
}
|
|
24
|
+
function getLocaleFromQuery() {
|
|
25
|
+
try {
|
|
26
|
+
const query = new URLSearchParams(window.location.search);
|
|
27
|
+
const locale = query.get('market') || query.get('locale');
|
|
28
|
+
return locale ? locale.toLowerCase() : '';
|
|
29
|
+
} catch (error) {
|
|
30
|
+
return '';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const a = {
|
|
34
|
+
_metadata: ${metadataJson},
|
|
35
|
+
getManifests: function () {
|
|
36
|
+
const manifests = JSON.parse(JSON.stringify(MANIFESTS_ARRAY), function (key, value) {
|
|
37
|
+
if (key === 'paths' && value && typeof value === 'object') {
|
|
38
|
+
if (typeof value.l === 'object' && value.l !== null && typeof value.p === 'string' && typeof value.s === 'string') {
|
|
39
|
+
const expanded = {};
|
|
40
|
+
for (const locale in value.l) {
|
|
41
|
+
expanded[locale] = { path: value.p + value.l[locale] + value.s };
|
|
42
|
+
}
|
|
43
|
+
return expanded;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return value;
|
|
47
|
+
});
|
|
48
|
+
const locale = getLocaleFromQuery();
|
|
49
|
+
for (let i = 0; i < manifests.length; i++) {
|
|
50
|
+
const loaderConfig = manifests[i].loaderConfig;
|
|
51
|
+
if (loaderConfig && loaderConfig.internalModuleBaseUrls && loaderConfig.internalModuleBaseUrls.length === 0) {
|
|
52
|
+
loaderConfig.internalModuleBaseUrls = [publicPath];
|
|
53
|
+
}
|
|
54
|
+
const scriptResources = loaderConfig && loaderConfig.scriptResources;
|
|
55
|
+
if (scriptResources) {
|
|
56
|
+
for (const name in scriptResources) {
|
|
57
|
+
const resource = scriptResources[name];
|
|
58
|
+
if (resource && resource.type === 'localizedPath' && resource.paths) {
|
|
59
|
+
const pathEntry = resource.paths[locale] || resource.paths['default'];
|
|
60
|
+
if (pathEntry) {
|
|
61
|
+
resource.path = pathEntry.path;
|
|
62
|
+
if (pathEntry.integrity !== undefined) {
|
|
63
|
+
resource.integrity = pathEntry.integrity;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return manifests;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
self.debugManifests = a;
|
|
74
|
+
window.debugManifests = a;
|
|
75
|
+
if (typeof define === 'function') {
|
|
76
|
+
define([], function () { return a; });
|
|
77
|
+
}
|
|
78
|
+
})();
|
|
79
|
+
`;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=manifests-js.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifests-js.js","sourceRoot":"","sources":["../src/manifests-js.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,SAAoB,EACpB,QAAkB;IAElB,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAChD,MAAM,YAAY,GAAG,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACrF,OAAO;4BACmB,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6BxB,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6C5B,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ComponentManifest } from './types.js';
|
|
2
|
+
export declare function ensureTrailingSlash(url: string): string;
|
|
3
|
+
export declare function joinUrlSegments(baseUrl: string, relativePath: string): string;
|
|
4
|
+
export declare function rewriteSpManifestForDebug(spManifest: unknown, relativePath: string, baseUrl: string): unknown;
|
|
5
|
+
export interface CollectDebugManifestsOptions {
|
|
6
|
+
projectRoot: string;
|
|
7
|
+
componentManifests: ComponentManifest[];
|
|
8
|
+
serverOrigin: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function collectDebugManifests(opts: CollectDebugManifestsOptions): Promise<unknown[]>;
|
|
11
|
+
//# sourceMappingURL=rewrite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rewrite.d.ts","sourceRoot":"","sources":["../src/rewrite.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAG7E;AAED,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,OAAO,EACnB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,GACd,OAAO,CAqBT;AAED,MAAM,WAAW,4BAA4B;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,iBAAiB,EAAE,CAAC;IACxC,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,4BAA4B,GACjC,OAAO,CAAC,OAAO,EAAE,CAAC,CAcpB"}
|
package/dist/rewrite.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { findSpDependencies } from './sp-dependencies.js';
|
|
3
|
+
export function ensureTrailingSlash(url) {
|
|
4
|
+
return url.endsWith('/') ? url : `${url}/`;
|
|
5
|
+
}
|
|
6
|
+
export function joinUrlSegments(baseUrl, relativePath) {
|
|
7
|
+
const base = baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl;
|
|
8
|
+
return `${base}/${relativePath.replace(/^\/+/, '')}`;
|
|
9
|
+
}
|
|
10
|
+
export function rewriteSpManifestForDebug(spManifest, relativePath, baseUrl) {
|
|
11
|
+
const manifest = spManifest;
|
|
12
|
+
if (!manifest.loaderConfig) {
|
|
13
|
+
return spManifest;
|
|
14
|
+
}
|
|
15
|
+
const encodedPath = encodeURI(relativePath.replace(/\\/g, '/'));
|
|
16
|
+
const url = joinUrlSegments(baseUrl, encodedPath);
|
|
17
|
+
const internalModuleBaseUrls = manifest.loaderConfig.internalModuleBaseUrls;
|
|
18
|
+
if (!internalModuleBaseUrls || internalModuleBaseUrls.length === 0) {
|
|
19
|
+
manifest.loaderConfig.internalModuleBaseUrls = [url];
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const firstUrl = internalModuleBaseUrls[0];
|
|
23
|
+
if (firstUrl === undefined || !firstUrl.startsWith(url)) {
|
|
24
|
+
internalModuleBaseUrls.unshift(url);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
manifest.loaderConfig.internalModuleBaseUrls =
|
|
28
|
+
(manifest.loaderConfig.internalModuleBaseUrls ?? [url]).map(ensureTrailingSlash);
|
|
29
|
+
return spManifest;
|
|
30
|
+
}
|
|
31
|
+
export async function collectDebugManifests(opts) {
|
|
32
|
+
const result = [...opts.componentManifests];
|
|
33
|
+
const spDependencies = findSpDependencies(opts.projectRoot);
|
|
34
|
+
const entries = [...spDependencies.entries()].sort((a, b) => a[0].localeCompare(b[0]));
|
|
35
|
+
for (const [pkgName, dependency] of entries) {
|
|
36
|
+
if (!dependency.manifestPath) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const raw = await fs.promises.readFile(dependency.manifestPath, 'utf8');
|
|
40
|
+
const manifest = JSON.parse(raw);
|
|
41
|
+
const relativePath = `node_modules/${pkgName}/dist`;
|
|
42
|
+
result.push(rewriteSpManifestForDebug(manifest, relativePath, opts.serverOrigin));
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=rewrite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rewrite.js","sourceRoot":"","sources":["../src/rewrite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,MAAM,UAAU,mBAAmB,CAAC,GAAW;IAC7C,OAAO,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAe,EAAE,YAAoB;IACnE,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IACpE,OAAO,GAAG,IAAI,IAAI,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,UAAmB,EACnB,YAAoB,EACpB,OAAe;IAEf,MAAM,QAAQ,GAAG,UAEhB,CAAC;IACF,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC;QAC3B,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,MAAM,WAAW,GAAG,SAAS,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;IAChE,MAAM,GAAG,GAAG,eAAe,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IAClD,MAAM,sBAAsB,GAAG,QAAQ,CAAC,YAAY,CAAC,s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AAE,MAAM,CAAC,CAAC;QACxE,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAY,CAAC;QAC5C,MAAM,YAAY,GAAG,gBAAgB,OAAO,OAAO,CAAC;QACpD,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IACpF,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sp-dependencies.d.ts","sourceRoot":"","sources":["../src/sp-dependencies.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB;AA2BD,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAiCjF"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { SP_COMPONENT_IDS } from './data/component-ids.js';
|
|
4
|
+
function readJson(filePath) {
|
|
5
|
+
try {
|
|
6
|
+
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function findDistManifest(pkgDir) {
|
|
13
|
+
const distDir = path.join(pkgDir, 'dist');
|
|
14
|
+
let files;
|
|
15
|
+
try {
|
|
16
|
+
files = fs.readdirSync(distDir);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
const manifestFiles = files
|
|
22
|
+
.filter((file) => file.endsWith('.manifest.json') && !file.startsWith('.'))
|
|
23
|
+
.sort();
|
|
24
|
+
if (manifestFiles.length === 0) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
return path.join(distDir, manifestFiles[0]);
|
|
28
|
+
}
|
|
29
|
+
export function findSpDependencies(projectRoot) {
|
|
30
|
+
const dependencies = new Map();
|
|
31
|
+
const microsoftDir = path.join(projectRoot, 'node_modules', '@microsoft');
|
|
32
|
+
let entries;
|
|
33
|
+
try {
|
|
34
|
+
entries = fs.readdirSync(microsoftDir, { withFileTypes: true });
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return dependencies;
|
|
38
|
+
}
|
|
39
|
+
for (const entry of entries) {
|
|
40
|
+
if ((!entry.isDirectory() && !entry.isSymbolicLink()) || entry.name.startsWith('.')) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const pkgDir = path.join(microsoftDir, entry.name);
|
|
44
|
+
const pkgJson = readJson(path.join(pkgDir, 'package.json'));
|
|
45
|
+
const pkgName = pkgJson && typeof pkgJson.name === 'string' && pkgJson.name.startsWith('@microsoft/')
|
|
46
|
+
? pkgJson.name
|
|
47
|
+
: `@microsoft/${entry.name}`;
|
|
48
|
+
const manifestPath = findDistManifest(pkgDir);
|
|
49
|
+
if (manifestPath) {
|
|
50
|
+
const manifest = readJson(manifestPath);
|
|
51
|
+
if (typeof manifest?.id === 'string' && typeof manifest.version === 'string') {
|
|
52
|
+
dependencies.set(pkgName, { id: manifest.id, version: manifest.version, manifestPath });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
const fallback = SP_COMPONENT_IDS[pkgName];
|
|
57
|
+
if (fallback) {
|
|
58
|
+
dependencies.set(pkgName, { id: fallback.id, version: fallback.version, manifestPath: '' });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return dependencies;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=sp-dependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sp-dependencies.js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CAAC,CAAC;YAC1F,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,QAAQ,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;YAC3C,IAAI,QAAQ,EAAE,CAAC;gBACb,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,CAAC;YAC9F,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface ComponentManifest {
|
|
2
|
+
id: string;
|
|
3
|
+
alias: string;
|
|
4
|
+
componentType: string;
|
|
5
|
+
version: string;
|
|
6
|
+
manifestVersion: number;
|
|
7
|
+
loaderConfig: {
|
|
8
|
+
internalModuleBaseUrls: string[];
|
|
9
|
+
entryModuleId: string;
|
|
10
|
+
scriptResources: Record<string, unknown>;
|
|
11
|
+
exportName?: string;
|
|
12
|
+
};
|
|
13
|
+
[k: string]: unknown;
|
|
14
|
+
}
|
|
15
|
+
export interface LocalizedResourceEntry {
|
|
16
|
+
name: string;
|
|
17
|
+
locales: string[];
|
|
18
|
+
}
|
|
19
|
+
export interface ManifestContext {
|
|
20
|
+
projectRoot: string;
|
|
21
|
+
production: boolean;
|
|
22
|
+
baseUrls: {
|
|
23
|
+
debug: string;
|
|
24
|
+
release: string[];
|
|
25
|
+
};
|
|
26
|
+
packageVersion: string;
|
|
27
|
+
bundleFiles: Map<string, string>;
|
|
28
|
+
externals: string[];
|
|
29
|
+
localizedResources?: LocalizedResourceEntry[];
|
|
30
|
+
webpartsDir?: string;
|
|
31
|
+
entryModuleIds?: Record<string, string>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE;QACZ,sBAAsB,EAAE,MAAM,EAAE,CAAC;QACjC,aAAa,EAAE,MAAM,CAAC;QACtB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACzC,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAC/C,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,kBAAkB,CAAC,EAAE,sBAAsB,EAAE,CAAC;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mbsks/rspfx-manifest-generator",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@mbsks/rspfx-core": "0.0.3",
|
|
21
|
+
"@mbsks/rspfx-diagnostics": "0.0.3"
|
|
22
|
+
},
|
|
23
|
+
"description": "RSPFX component manifest generation (manifests, manifests.js, sp-* deps)",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/master8848/rspfx.git"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc -p tsconfig.build.json",
|
|
30
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
31
|
+
"test": "vitest run"
|
|
32
|
+
}
|
|
33
|
+
}
|