diff --git a/packages/sku/src/context/configSchema.ts b/packages/sku/src/context/configSchema.ts index d981715ab..bcc121b83 100644 --- a/packages/sku/src/context/configSchema.ts +++ b/packages/sku/src/context/configSchema.ts @@ -1,7 +1,6 @@ import Validator from 'fastest-validator'; -// @ts-expect-error -const validator = new Validator(); +const validator = new (Validator as unknown as typeof Validator.default)(); const languagesToCompile = { optional: true, diff --git a/packages/sku/src/context/defaultSkuConfig.ts b/packages/sku/src/context/defaultSkuConfig.ts index aff81686c..eca824058 100644 --- a/packages/sku/src/context/defaultSkuConfig.ts +++ b/packages/sku/src/context/defaultSkuConfig.ts @@ -3,7 +3,7 @@ import { join } from 'node:path'; import isCompilePackage from '../lib/isCompilePackage.js'; import type { SkuConfig } from '../../sku-types.d.ts'; -const defaultDecorator = (a: any) => a; +const defaultDecorator = (a: T) => a; export default { clientEntry: 'src/client.js', diff --git a/packages/sku/src/context/validateConfig.ts b/packages/sku/src/context/validateConfig.ts index 5ba0d2920..2286f3229 100644 --- a/packages/sku/src/context/validateConfig.ts +++ b/packages/sku/src/context/validateConfig.ts @@ -7,6 +7,7 @@ import defaultSkuConfig from './defaultSkuConfig.js'; import defaultClientEntry from './defaultClientEntry.js'; import type { SkuConfig } from '../../sku-types.d.ts'; import { hasErrorMessage } from '../lib/utils/error-guards.js'; +import type { ValidationError } from 'fastest-validator'; const availableConfigKeys = Object.keys(defaultSkuConfig); @@ -34,17 +35,17 @@ export default (skuConfig: SkuConfig) => { }); // Validate schema types - const schemaCheckResult = configSchema(skuConfig); - if (schemaCheckResult !== true) { - schemaCheckResult.forEach( - ({ message, field }: { message: string; field: string }) => { + if (!configSchema.async) { + const schemaCheckResult = configSchema(skuConfig); + if (schemaCheckResult !== true) { + schemaCheckResult.forEach(({ message, field }: ValidationError) => { const errorMessage = message ? `🚫 ${message.replace(field, `${chalk.bold(field)}`)}` : `🚫 '${chalk.bold(field)}' is invalid`; errors.push(errorMessage); - }, - ); + }); + } } // Validate library entry has corresponding libraryName diff --git a/packages/sku/src/entry/client/index.tsx b/packages/sku/src/entry/client/index.tsx index 6c1b3c529..68f384d67 100644 --- a/packages/sku/src/entry/client/index.tsx +++ b/packages/sku/src/entry/client/index.tsx @@ -1,6 +1,7 @@ // '__sku_alias__clientEntry' is a webpack alias // pointing to the consuming apps client entry import client from '__sku_alias__clientEntry'; +import dedent from 'dedent'; import { loadableReady } from '@loadable/component'; @@ -8,8 +9,7 @@ import clientContextKey from '../clientContextKey.js'; if (process.env.NODE_ENV === 'development') { if (typeof client !== 'function') { - // eslint-disable-next-line - throw new Error(require('dedent')` + throw new Error(dedent` The sku client entry ('${__SKU_CLIENT_PATH__}') must export a function that calls hydrateRoot. e.g. import { hydrateRoot } from 'react-dom/client'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 726f54f0f..f4ed5e7b9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -46,7 +46,7 @@ importers: version: 9.15.0(jiti@2.4.1) eslint-config-seek: specifier: ^14.2.0 - version: 14.2.0(@typescript-eslint/eslint-plugin@8.15.0(@typescript-eslint/parser@8.15.0(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3))(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3))(@typescript-eslint/parser@8.15.0(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3))(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.15.0(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3))(eslint@9.15.0(jiti@2.4.1)))(eslint@9.15.0(jiti@2.4.1))(jest@29.7.0(@types/node@18.19.57)(babel-plugin-macros@3.1.0))(typescript@5.6.3) + version: 14.2.0(@typescript-eslint/eslint-plugin@8.15.0(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3))(eslint-plugin-import@2.31.0(eslint@9.15.0(jiti@2.4.1)))(eslint@9.15.0(jiti@2.4.1))(jest@29.7.0(@types/node@18.19.57)(babel-plugin-macros@3.1.0))(typescript@5.6.3) eslint-plugin-jsdoc: specifier: ^50.2.2 version: 50.5.0(eslint@9.15.0(jiti@2.4.1)) @@ -703,7 +703,7 @@ importers: version: 1.1.0 debug: specifier: ^4.3.1 - version: 4.3.7(supports-color@8.1.1) + version: 4.3.7 dedent: specifier: ^1.5.1 version: 1.5.3(babel-plugin-macros@3.1.0) @@ -2833,8 +2833,8 @@ packages: '@types/express-serve-static-core@4.19.6': resolution: {integrity: sha512-N4LZ2xG7DatVqhCZzOGb1Yi5lMbXSZcmdLDe9EzSndPV2HpWYWzRbaerl2n27irrm94EPpprqa8KpskPT085+A==} - '@types/express-serve-static-core@5.0.0': - resolution: {integrity: sha512-AbXMTZGt40T+KON9/Fdxx0B2WK5hsgxcfXJLr5bFpZ7b4JCex2WyQPTEKdXqfHiY5nKKBScZ7yCoO6Pvgxfvnw==} + '@types/express-serve-static-core@5.0.2': + resolution: {integrity: sha512-vluaspfvWEtE4vcSDlKRNer52DvOGrB2xv6diXy6UKyKW0lqZiWHGNApSyxOv+8DE5Z27IzVvE7hNkxg7EXIcg==} '@types/express@4.17.21': resolution: {integrity: sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ==} @@ -8767,7 +8767,7 @@ snapshots: '@babel/traverse': 7.25.7 '@babel/types': 7.26.0 convert-source-map: 2.0.0 - debug: 4.3.7(supports-color@8.1.1) + debug: 4.3.7 gensync: 1.0.0-beta.2 json5: 2.2.3 semver: 6.3.1 @@ -8830,7 +8830,7 @@ snapshots: '@babel/core': 7.25.8 '@babel/helper-compilation-targets': 7.25.7 '@babel/helper-plugin-utils': 7.25.7 - debug: 4.3.7(supports-color@8.1.1) + debug: 4.3.7 lodash.debounce: 4.0.8 resolve: 1.22.8 transitivePeerDependencies: @@ -9569,7 +9569,7 @@ snapshots: '@babel/parser': 7.25.8 '@babel/template': 7.25.7 '@babel/types': 7.26.0 - debug: 4.3.7(supports-color@8.1.1) + debug: 4.3.7 globals: 11.12.0 transitivePeerDependencies: - supports-color @@ -9908,7 +9908,7 @@ snapshots: '@eslint/config-array@0.19.0': dependencies: '@eslint/object-schema': 2.1.4 - debug: 4.3.7(supports-color@8.1.1) + debug: 4.3.7 minimatch: 3.1.2 transitivePeerDependencies: - supports-color @@ -9918,7 +9918,7 @@ snapshots: '@eslint/eslintrc@3.2.0': dependencies: ajv: 6.12.6 - debug: 4.3.7(supports-color@8.1.1) + debug: 4.3.7 espree: 10.3.0 globals: 14.0.0 ignore: 5.3.2 @@ -10860,7 +10860,7 @@ snapshots: '@types/connect-history-api-fallback@1.5.4': dependencies: - '@types/express-serve-static-core': 5.0.0 + '@types/express-serve-static-core': 5.0.2 '@types/node': 18.19.57 '@types/connect@3.4.38': @@ -10903,7 +10903,7 @@ snapshots: '@types/range-parser': 1.2.7 '@types/send': 0.17.4 - '@types/express-serve-static-core@5.0.0': + '@types/express-serve-static-core@5.0.2': dependencies: '@types/node': 18.19.57 '@types/qs': 6.9.16 @@ -11176,7 +11176,7 @@ snapshots: '@typescript-eslint/types': 8.15.0 '@typescript-eslint/typescript-estree': 8.15.0(typescript@5.6.3) '@typescript-eslint/visitor-keys': 8.15.0 - debug: 4.3.7(supports-color@8.1.1) + debug: 4.3.7 eslint: 9.15.0(jiti@2.4.1) optionalDependencies: typescript: 5.6.3 @@ -11192,7 +11192,7 @@ snapshots: dependencies: '@typescript-eslint/typescript-estree': 8.15.0(typescript@5.6.3) '@typescript-eslint/utils': 8.15.0(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3) - debug: 4.3.7(supports-color@8.1.1) + debug: 4.3.7 eslint: 9.15.0(jiti@2.4.1) ts-api-utils: 1.4.0(typescript@5.6.3) optionalDependencies: @@ -11206,7 +11206,7 @@ snapshots: dependencies: '@typescript-eslint/types': 8.15.0 '@typescript-eslint/visitor-keys': 8.15.0 - debug: 4.3.7(supports-color@8.1.1) + debug: 4.3.7 fast-glob: 3.3.2 is-glob: 4.0.3 minimatch: 9.0.5 @@ -11316,7 +11316,7 @@ snapshots: '@vanilla-extract/webpack-plugin@2.3.14(@types/node@18.19.57)(babel-plugin-macros@3.1.0)(terser@5.36.0)(webpack@5.95.0(@swc/core@1.7.36))': dependencies: '@vanilla-extract/integration': 7.1.10(@types/node@18.19.57)(babel-plugin-macros@3.1.0)(terser@5.36.0) - debug: 4.3.7(supports-color@8.1.1) + debug: 4.3.7 loader-utils: 2.0.4 picocolors: 1.1.1 webpack: 5.95.0(@swc/core@1.7.36) @@ -11336,7 +11336,7 @@ snapshots: dependencies: '@formatjs/icu-messageformat-parser': 2.7.10 chokidar: 3.6.0 - debug: 4.3.7(supports-color@8.1.1) + debug: 4.3.7 fast-glob: 3.3.2 fastest-validator: 1.19.0 find-up: 5.0.0 @@ -11350,7 +11350,7 @@ snapshots: dependencies: '@vocab/core': 1.6.2 csv-stringify: 6.5.1 - debug: 4.3.7(supports-color@8.1.1) + debug: 4.3.7 picocolors: 1.1.1 transitivePeerDependencies: - supports-color @@ -11369,7 +11369,7 @@ snapshots: dependencies: '@vocab/core': 1.6.2 cjs-module-lexer: 1.4.1 - debug: 4.3.7(supports-color@8.1.1) + debug: 4.3.7 es-module-lexer: 1.5.4 picocolors: 1.1.1 virtual-resource-loader: 1.0.1 @@ -11516,7 +11516,7 @@ snapshots: agent-base@6.0.2: dependencies: - debug: 4.3.7(supports-color@8.1.1) + debug: 4.3.7 transitivePeerDependencies: - supports-color @@ -12581,6 +12581,10 @@ snapshots: dependencies: ms: 2.1.3 + debug@4.3.7: + dependencies: + ms: 2.1.3 + debug@4.3.7(supports-color@8.1.1): dependencies: ms: 2.1.3 @@ -13127,6 +13131,28 @@ snapshots: - jest - supports-color + eslint-config-seek@14.2.0(@typescript-eslint/eslint-plugin@8.15.0(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3))(eslint-plugin-import@2.31.0(eslint@9.15.0(jiti@2.4.1)))(eslint@9.15.0(jiti@2.4.1))(jest@29.7.0(@types/node@18.19.57)(babel-plugin-macros@3.1.0))(typescript@5.6.3): + dependencies: + eslint: 9.15.0(jiti@2.4.1) + eslint-config-prettier: 9.1.0(eslint@9.15.0(jiti@2.4.1)) + eslint-import-resolver-typescript: 3.6.3(eslint-plugin-import-x@4.2.1(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3))(eslint-plugin-import@2.31.0(eslint@9.15.0(jiti@2.4.1)))(eslint@9.15.0(jiti@2.4.1)) + eslint-plugin-cypress: 3.6.0(eslint@9.15.0(jiti@2.4.1)) + eslint-plugin-import-x: 4.2.1(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3) + eslint-plugin-jest: 28.8.3(@typescript-eslint/eslint-plugin@8.15.0(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3))(eslint@9.15.0(jiti@2.4.1))(jest@29.7.0(@types/node@18.19.57)(babel-plugin-macros@3.1.0))(typescript@5.6.3) + eslint-plugin-react: 7.37.2(eslint@9.15.0(jiti@2.4.1)) + eslint-plugin-react-hooks: 5.0.0(eslint@9.15.0(jiti@2.4.1)) + globals: 15.12.0 + typescript: 5.6.3 + typescript-eslint: 8.15.0(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3) + transitivePeerDependencies: + - '@typescript-eslint/eslint-plugin' + - '@typescript-eslint/parser' + - eslint-import-resolver-node + - eslint-import-resolver-webpack + - eslint-plugin-import + - jest + - supports-color + eslint-import-resolver-node@0.3.9: dependencies: debug: 3.2.7 @@ -13138,7 +13164,7 @@ snapshots: eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@8.15.0(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3))(eslint-plugin-import-x@4.2.1(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3))(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.15.0(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3))(eslint@9.15.0(jiti@2.4.1)))(eslint@9.15.0(jiti@2.4.1)): dependencies: '@nolyfill/is-core-module': 1.0.39 - debug: 4.3.7(supports-color@8.1.1) + debug: 4.3.7 enhanced-resolve: 5.17.1 eslint: 9.15.0(jiti@2.4.1) eslint-module-utils: 2.12.0(@typescript-eslint/parser@8.15.0(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3))(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@8.15.0(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3))(eslint-plugin-import-x@4.2.1(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3))(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.15.0(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3))(eslint@9.15.0(jiti@2.4.1)))(eslint@9.15.0(jiti@2.4.1)))(eslint@9.15.0(jiti@2.4.1)) @@ -13155,6 +13181,26 @@ snapshots: - eslint-import-resolver-webpack - supports-color + eslint-import-resolver-typescript@3.6.3(eslint-plugin-import-x@4.2.1(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3))(eslint-plugin-import@2.31.0(eslint@9.15.0(jiti@2.4.1)))(eslint@9.15.0(jiti@2.4.1)): + dependencies: + '@nolyfill/is-core-module': 1.0.39 + debug: 4.3.7(supports-color@8.1.1) + enhanced-resolve: 5.17.1 + eslint: 9.15.0(jiti@2.4.1) + eslint-module-utils: 2.12.0(eslint-import-resolver-typescript@3.6.3(eslint-plugin-import-x@4.2.1(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3))(eslint-plugin-import@2.31.0(eslint@9.15.0(jiti@2.4.1)))(eslint@9.15.0(jiti@2.4.1)))(eslint@9.15.0(jiti@2.4.1)) + fast-glob: 3.3.2 + get-tsconfig: 4.8.1 + is-bun-module: 1.2.1 + is-glob: 4.0.3 + optionalDependencies: + eslint-plugin-import: 2.31.0(@typescript-eslint/parser@8.15.0(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3))(eslint@9.15.0(jiti@2.4.1)) + eslint-plugin-import-x: 4.2.1(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3) + transitivePeerDependencies: + - '@typescript-eslint/parser' + - eslint-import-resolver-node + - eslint-import-resolver-webpack + - supports-color + eslint-module-utils@2.12.0(@typescript-eslint/parser@8.15.0(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint@9.15.0(jiti@2.4.1)): dependencies: debug: 3.2.7 @@ -13176,6 +13222,15 @@ snapshots: transitivePeerDependencies: - supports-color + eslint-module-utils@2.12.0(eslint-import-resolver-typescript@3.6.3(eslint-plugin-import-x@4.2.1(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3))(eslint-plugin-import@2.31.0(eslint@9.15.0(jiti@2.4.1)))(eslint@9.15.0(jiti@2.4.1)))(eslint@9.15.0(jiti@2.4.1)): + dependencies: + debug: 3.2.7 + optionalDependencies: + eslint: 9.15.0(jiti@2.4.1) + eslint-import-resolver-typescript: 3.6.3(eslint-plugin-import-x@4.2.1(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3))(eslint-plugin-import@2.31.0(eslint@9.15.0(jiti@2.4.1)))(eslint@9.15.0(jiti@2.4.1)) + transitivePeerDependencies: + - supports-color + eslint-plugin-cypress@3.6.0(eslint@9.15.0(jiti@2.4.1)): dependencies: eslint: 9.15.0(jiti@2.4.1) @@ -13184,7 +13239,7 @@ snapshots: eslint-plugin-import-x@4.2.1(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3): dependencies: '@typescript-eslint/utils': 8.15.0(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3) - debug: 4.3.7(supports-color@8.1.1) + debug: 4.3.7 doctrine: 3.0.0 eslint: 9.15.0(jiti@2.4.1) eslint-import-resolver-node: 0.3.9 @@ -13239,6 +13294,17 @@ snapshots: - supports-color - typescript + eslint-plugin-jest@28.8.3(@typescript-eslint/eslint-plugin@8.15.0(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3))(eslint@9.15.0(jiti@2.4.1))(jest@29.7.0(@types/node@18.19.57)(babel-plugin-macros@3.1.0))(typescript@5.6.3): + dependencies: + '@typescript-eslint/utils': 8.15.0(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3) + eslint: 9.15.0(jiti@2.4.1) + optionalDependencies: + '@typescript-eslint/eslint-plugin': 8.15.0(@typescript-eslint/parser@8.15.0(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3))(eslint@9.15.0(jiti@2.4.1))(typescript@5.6.3) + jest: 29.7.0(@types/node@18.19.57)(babel-plugin-macros@3.1.0) + transitivePeerDependencies: + - supports-color + - typescript + eslint-plugin-jsdoc@50.5.0(eslint@9.15.0(jiti@2.4.1)): dependencies: '@es-joy/jsdoccomment': 0.49.0 @@ -13333,7 +13399,7 @@ snapshots: ajv: 6.12.6 chalk: 4.1.2 cross-spawn: 7.0.6 - debug: 4.3.7(supports-color@8.1.1) + debug: 4.3.7 escape-string-regexp: 4.0.0 eslint-scope: 8.2.0 eslint-visitor-keys: 4.2.0 @@ -13673,7 +13739,7 @@ snapshots: follow-redirects@1.15.9(debug@4.3.7): optionalDependencies: - debug: 4.3.7(supports-color@8.1.1) + debug: 4.3.7 for-each@0.3.3: dependencies: @@ -14158,7 +14224,7 @@ snapshots: dependencies: '@tootallnate/once': 2.0.0 agent-base: 6.0.2 - debug: 4.3.7(supports-color@8.1.1) + debug: 4.3.7 transitivePeerDependencies: - supports-color @@ -14192,7 +14258,7 @@ snapshots: https-proxy-agent@5.0.1: dependencies: agent-base: 6.0.2 - debug: 4.3.7(supports-color@8.1.1) + debug: 4.3.7 transitivePeerDependencies: - supports-color @@ -14565,7 +14631,7 @@ snapshots: istanbul-lib-source-maps@4.0.1: dependencies: - debug: 4.3.7(supports-color@8.1.1) + debug: 4.3.7 istanbul-lib-coverage: 3.2.2 source-map: 0.6.1 transitivePeerDependencies: @@ -15129,7 +15195,7 @@ snapshots: dependencies: chalk: 5.3.0 commander: 12.1.0 - debug: 4.3.7(supports-color@8.1.1) + debug: 4.3.7 execa: 8.0.1 lilconfig: 3.1.2 listr2: 8.2.5 @@ -16935,7 +17001,7 @@ snapshots: spdy-transport@3.0.0: dependencies: - debug: 4.3.7(supports-color@8.1.1) + debug: 4.3.7 detect-node: 2.1.0 hpack.js: 2.1.6 obuf: 1.1.2 @@ -16946,7 +17012,7 @@ snapshots: spdy@4.0.2: dependencies: - debug: 4.3.7(supports-color@8.1.1) + debug: 4.3.7 handle-thing: 2.0.1 http-deceiver: 1.2.7 select-hose: 2.0.0 @@ -17555,7 +17621,7 @@ snapshots: vite-node@1.6.0(@types/node@18.19.57)(terser@5.36.0): dependencies: cac: 6.7.14 - debug: 4.3.7(supports-color@8.1.1) + debug: 4.3.7 pathe: 1.1.2 picocolors: 1.1.1 vite: 5.4.9(@types/node@18.19.57)(terser@5.36.0)