Refactor libs into @umbraco-cms/backoffice/* (#608)

* merge libs rollup configs to one rollup

* move css from libs to src/core

* run rollup on cms build

* move test-utils to /utils folder

* move css to src/core

* mark @umbraco-cms/backoffice as external when building for CMS

* rename all models to include @umbraco-cms/backoffice in their path to allow us to publish as a single module

* rename all imports to @umbraco-cms/backoffice/*

* rename events to umb-events to avoid rollup error of protected module name(?)

* test that libs can build

* move css to src/core

* move umb-lit-element and modal elements to src/core

* move some modal interfaces back to libs/modal

* move the icon store into src/core since it is very localized to the backoffice

* comment out build:libs for now since Github runs out of memory

* rename to match tsconfig alias

* add package.json to libs

* only make libs for lib folders

* turn off emit for typescript since we are handling types for libs separately

* build libs locally

* add script to move libs to final destination with some transform

* move libs after build

* move package.json to dist folder first (so we can publish from there)

* remove inline comments

* ensure the outputDir exists

* Remove re-export of extensions-registry library from models library

* move to individual files to avoid circular imports

* check if outputDir exists before trying to create it

* write transforms first in dist file and then copy the file to outputDir

* ensure all umbraco types are external

* copy information from main package.json file
This commit is contained in:
Jacob Overgaard
2023-03-21 11:41:06 +01:00
committed by GitHub
parent c905d40c23
commit 796533ff11
1447 changed files with 1888 additions and 1761 deletions

View File

@@ -0,0 +1,49 @@
// Load all .d.ts files from the dist/libs folder
// and replace all imports from @umbraco-cms/backoffice with relative imports
// Example: import { Foo } from '@umbraco-cms/backoffice/element' -> import { Foo } from './element'
// This is needed because the d.ts files are not in the same folder as the source files
// and the absolute paths are not valid when the d.ts files are copied to the dist folder
// This is only used when building the d.ts files
//
// Usage: node utils/transform-dts.js
//
// Note: This script is not used in the build process, it is only used to transform the d.ts files
// when the d.ts files are copied to the dist folder
import { readdirSync, readFileSync, writeFileSync, cpSync, mkdirSync, lstatSync } from 'fs';
const srcDir = './libs';
const inputDir = './dist/libs';
const outputDir = '../Umbraco.Cms.StaticAssets/wwwroot/umbraco/backoffice/libs';
// Copy package.json
cpSync(`${srcDir}/package.json`, `${inputDir}/package.json`, { recursive: true });
const libs = readdirSync(inputDir);
// Create output folder
if (!lstatSync(outputDir)) {
mkdirSync(outputDir, { recursive: true });
}
// Transform all .d.ts files and copy all other files to the output folder
libs.forEach(lib => {
console.log(`Transforming ${lib}`);
const dtsFile = `${inputDir}/${lib}`;
let code = readFileSync(dtsFile, 'utf8');
// Replace all absolute imports with relative imports
if (lib.endsWith('.d.ts')) {
code = code.replace(/from '(@umbraco-cms\/backoffice\/[^']+)'/g, (match, p1) => {
return `from './${p1.split('/').pop()}'`;
});
}
writeFileSync(dtsFile, code, 'utf8');
cpSync(dtsFile, `${outputDir}/${lib}`, { recursive: true });
});

View File

@@ -1,27 +0,0 @@
import esbuild from 'rollup-plugin-esbuild';
import pluginJson from '@rollup/plugin-json';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import dts from 'rollup-plugin-dts';
/** @type {import('rollup').RollupOptions[]} */
export default [
{
input: 'index.ts',
external: [/^@umbraco-cms\//, /^lit/],
output: {
file: 'dist/index.js',
format: 'es',
sourcemap: true
},
plugins: [nodeResolve(), pluginJson(), esbuild()]
},
{
input: 'index.ts',
external: [/^@umbraco-cms\//, /^lit/, /^rxjs/],
output: {
file: './dist/index.d.ts',
format: 'es'
},
plugins: [dts({ respectExternal: true })],
}
];

View File

@@ -0,0 +1,3 @@
export const defaultA11yConfig = {
ignoredRules: [],
};