Ship /src/lib in ESM for enabeling dynamic imports

This commit is contained in:
garronej
2022-07-29 23:10:35 +02:00
parent 449f100bc0
commit d79081dee4
19 changed files with 69 additions and 25 deletions

View File

@ -4,7 +4,7 @@ import type { KcProps } from "./KcProps";
import type { KcContextBase } from "../getKcContext/KcContextBase";
import { getMsg } from "../i18n";
import { headInsert } from "../tools/headInsert";
import { pathJoin } from "../tools/pathJoin";
import { pathJoin } from "../../bin/tools/pathJoin";
import { useCssAndCx } from "tss-react";
const LoginOtp = memo(({ kcContext, ...props }: { kcContext: KcContextBase.LoginOtp } & KcProps) => {

View File

@ -6,7 +6,7 @@ import type { KcContextBase } from "../getKcContext/KcContextBase";
import { assert } from "../tools/assert";
import { useCallbackFactory } from "powerhooks/useCallbackFactory";
import { headInsert } from "../tools/headInsert";
import { pathJoin } from "../tools/pathJoin";
import { pathJoin } from "../../bin/tools/pathJoin";
import { useConstCallback } from "powerhooks/useConstCallback";
import type { KcTemplateProps } from "./KcProps";
import { useCssAndCx } from "tss-react";

View File

@ -7,9 +7,9 @@ import { exclude } from "tsafe/exclude";
import { assert } from "tsafe/assert";
import type { ExtendsKcContextBase } from "./getKcContextFromWindow";
import { getKcContextFromWindow } from "./getKcContextFromWindow";
import { pathJoin } from "../tools/pathJoin";
import { pathJoin } from "../../bin/tools/pathJoin";
import { pathBasename } from "../tools/pathBasename";
import { resourcesCommonPath } from "./kcContextMocks/urlResourcesPath";
import { resourcesCommonPath } from "../../bin/urlResourcesPath";
export function getKcContext<KcContextExtended extends { pageId: string } = never>(params?: {
mockPageId?: ExtendsKcContextBase<KcContextExtended>["pageId"];

View File

@ -1,9 +1,9 @@
import "minimal-polyfills/Object.fromEntries";
import type { KcContextBase, Attribute } from "../KcContextBase";
//NOTE: Aside because we want to be able to import them from node
import { resourcesCommonPath, resourcesPath } from "./urlResourcesPath";
import { resourcesCommonPath, resourcesPath } from "../../../bin/urlResourcesPath";
import { id } from "tsafe/id";
import { pathJoin } from "../../tools/pathJoin";
import { pathJoin } from "../../../bin/tools/pathJoin";
const PUBLIC_URL = process.env["PUBLIC_URL"] ?? "/";

View File

@ -1,5 +0,0 @@
import { pathJoin } from "../../tools/pathJoin";
export const subDirOfPublicDirBasename = "keycloak_static";
export const resourcesPath = pathJoin(subDirOfPublicDirBasename, "resources");
export const resourcesCommonPath = pathJoin(resourcesPath, "resources_common");

View File

@ -1,6 +0,0 @@
export function pathJoin(...path: string[]): string {
return path
.map((part, i) => (i === 0 ? part : part.replace(/^\/+/, "")))
.map((part, i) => (i === path.length - 1 ? part : part.replace(/\/+$/, "")))
.join("/");
}

18
src/lib/tsconfig.json Normal file
View File

@ -0,0 +1,18 @@
{
"extends": "../../tsproject.json",
"compilerOptions": {
"outDir": "../../dist/lib",
"rootDir": ".",
"module": "ES2020",
"target": "ES2020",
"lib": ["es2015", "DOM", "ES2019.Object"],
"moduleResolution": "node",
"jsx": "react-jsx",
"allowSyntheticDefaultImports": true
},
"references": [
{
"path": "../bin"
}
]
}