Merge branch 'release/15.0'
This commit is contained in:
25
src/Umbraco.Web.UI.Client/devops/build/global-types.js
Normal file
25
src/Umbraco.Web.UI.Client/devops/build/global-types.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import { createImportMap } from '../importmap/index.js';
|
||||
import { writeFileWithDir } from '../utils/index.js';
|
||||
|
||||
const tsPath = './dist-cms/packages/extension-types/index.d.ts';
|
||||
|
||||
const importmap = createImportMap({
|
||||
rootDir: './src',
|
||||
replaceModuleExtensions: true,
|
||||
});
|
||||
|
||||
const paths = Object.keys(importmap.imports);
|
||||
|
||||
const content = `
|
||||
${paths.map((path) => `import '${path}';`).join('\n')}
|
||||
`;
|
||||
|
||||
writeFileWithDir(tsPath, content, (err) => {
|
||||
if (err) {
|
||||
// eslint-disable-next-line no-undef
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
console.log(`global-types file generated`);
|
||||
});
|
||||
@@ -8,14 +8,14 @@ export const createImportMap = (args) => {
|
||||
// Iterate over the exports in package.json
|
||||
for (const [key, value] of Object.entries(packageJsonExports || {})) {
|
||||
// remove leading ./
|
||||
if (value) {
|
||||
if (value && value.endsWith('.js')) {
|
||||
const moduleName = key.replace(/^\.\//, '');
|
||||
|
||||
// replace ./dist-cms with src and remove /index.js
|
||||
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)
|
||||
console.log('replacing', value, 'with', modulePath);
|
||||
const importAlias = `${packageJsonName}/${moduleName}`;
|
||||
|
||||
imports[importAlias] = modulePath;
|
||||
|
||||
13
src/Umbraco.Web.UI.Client/devops/utils/index.js
Normal file
13
src/Umbraco.Web.UI.Client/devops/utils/index.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import { writeFile, mkdir } from 'fs';
|
||||
import * as pathModule from 'path';
|
||||
|
||||
const path = pathModule.default;
|
||||
const getDirName = path.dirname;
|
||||
|
||||
export const writeFileWithDir = (path, contents, cb) => {
|
||||
mkdir(getDirName(path), { recursive: true }, function (err) {
|
||||
if (err) return cb(err);
|
||||
|
||||
writeFile(path, contents, cb);
|
||||
});
|
||||
};
|
||||
@@ -12,6 +12,7 @@
|
||||
"./element-api": "./dist-cms/libs/element-api/index.js",
|
||||
"./embedded-media": "./dist-cms/packages/embedded-media/index.js",
|
||||
"./extension-api": "./dist-cms/libs/extension-api/index.js",
|
||||
"./extension-types": "./dist-cms/packages/extension-types/index.d.ts",
|
||||
"./formatting-api": "./dist-cms/libs/formatting-api/index.js",
|
||||
"./localization-api": "./dist-cms/libs/localization-api/index.js",
|
||||
"./observable-api": "./dist-cms/libs/observable-api/index.js",
|
||||
@@ -152,7 +153,7 @@
|
||||
"build:vite": "tsc && vite build --mode staging",
|
||||
"build:workspaces": "npm run build -ws --if-present",
|
||||
"build": "tsc --project ./src/tsconfig.build.json",
|
||||
"postbuild": "rollup -c ./src/rollup.config.js",
|
||||
"postbuild": "rollup -c ./src/rollup.config.js && node ./devops/build/global-types.js",
|
||||
"check": "npm run lint:errors && npm run compile && npm run build-storybook && npm run generate:jsonschema:dist",
|
||||
"check:paths": "node ./devops/build/check-path-length.js dist-cms 120",
|
||||
"check:circular": "madge --circular --warning --extensions ts ./src",
|
||||
|
||||
Reference in New Issue
Block a user