Hotfix: Expose global types (#2442)

* add script

* run script post build

* remove unused script

* add types to root import

* add util

* build to packages folder

* Update global-types.js

* only include js files in importmap
This commit is contained in:
Mads Rasmussen
2024-10-11 08:22:51 +02:00
committed by GitHub
parent 1ecf9c5c51
commit 11f69be335
4 changed files with 42 additions and 3 deletions

View File

@@ -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;