generate an umbraco-package.json file containing the general importmap of the backoffice
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { createImportMap } from "../importmap/index.js";
|
||||
import { writeFileSync, rmSync } from "fs";
|
||||
import { packageJsonName, packageJsonVersion } from "../package/index.js";
|
||||
|
||||
const srcDir = './dist-cms';
|
||||
const outputModuleList = `${srcDir}/umbraco-package.json`;
|
||||
const importmap = createImportMap({ rootDir: '/umbraco/backoffice', additionalImports: {} });
|
||||
|
||||
const umbracoPackageJson = {
|
||||
name: packageJsonName,
|
||||
version: packageJsonVersion,
|
||||
extensions: [],
|
||||
importmap
|
||||
};
|
||||
|
||||
try {
|
||||
rmSync(outputModuleList, { force: true });
|
||||
writeFileSync(outputModuleList, JSON.stringify(umbracoPackageJson));
|
||||
console.log(`Wrote manifest to ${outputModuleList}`);
|
||||
} catch (e) {
|
||||
console.error(`Failed to write manifest to ${outputModuleList}`, e);
|
||||
process.exit(1);
|
||||
}
|
||||
@@ -12,7 +12,9 @@ export const createImportMap = (args) => {
|
||||
const moduleName = key.replace(/^\.\//, '');
|
||||
|
||||
// replace ./dist-cms with src and remove /index.js
|
||||
const modulePath = value.replace(/^\.\/dist-cms/, args.rootDir).replace('.js', '.ts');
|
||||
let modulePath = value;
|
||||
if (typeof args.rootDir !== 'undefined') modulePath = modulePath.replace(/^\.\/dist-cms/, args.rootDir);
|
||||
if (args.replaceModuleExtensions) modulePath = modulePath.replace('.js', '.ts');
|
||||
console.log('replacing', value, 'with', modulePath)
|
||||
const importAlias = `${packageJsonName}/${moduleName}`;
|
||||
|
||||
|
||||
@@ -3,4 +3,5 @@ import { readFileSync } from 'fs';
|
||||
export const packageJsonPath = 'package.json';
|
||||
export const packageJsonData = JSON.parse(readFileSync(packageJsonPath).toString());
|
||||
export const packageJsonName = packageJsonData.name;
|
||||
export const packageJsonVersion = packageJsonData.version;
|
||||
export const packageJsonExports = packageJsonData.exports;
|
||||
|
||||
@@ -42,6 +42,7 @@ const importmap = createImportMap({
|
||||
additionalImports: {
|
||||
'@umbraco-cms/internal/test-utils': './utils/test-utils.ts',
|
||||
},
|
||||
replaceModuleExtensions: true,
|
||||
});
|
||||
|
||||
const paths = {};
|
||||
|
||||
Reference in New Issue
Block a user