From 015040f09667b2f6672120b84c988404e415cc17 Mon Sep 17 00:00:00 2001 From: Alex Prudhomme <78121423+alexprudhomme@users.noreply.github.com> Date: Fri, 20 Sep 2024 12:20:59 -0400 Subject: [PATCH] fix errors (#4444) All errors are fixed. Warnings left that I cant fix : 1. The types errors for commonJS are not urgent 2. I can't find how to tell stencil to generate commonjs files as .cjs instead of .js ``` npx publint ./node_modules/@coveo/atomic-react @coveo/atomic-react lint results: Warnings: 1. pkg.exports["."].types types is interpreted as ESM when resolving with the "require" condition. This causes the types to only work when dynamically importing the package, even though the package exports CJS. Consider splitting out two "types" conditions for "import" and "require", and use the .cts extension, e.g. pkg.exports["."].require.types: "./dist/index.d.cts" npx publint ./node_modules/@coveo/atomic @coveo/atomic lint results: Warnings: 1. pkg.main is dist/index.cjs.js and is written in CJS, but is interpreted as ESM. Consider using the .cjs extension, e.g. dist/index.cjs.cjs 3. pkg.exports["."].require is ./dist/index.cjs.js and is written in CJS, but is interpreted as ESM. Consider using the .cjs extension, e.g. ./dist/index.cjs.cjs 4. pkg.exports["."].types types is interpreted as ESM when resolving with the "require" condition. This causes the types to only work when dynamically importing the package, even though the package exports CJS. Consider splitting out two "types" conditions for "import" and "require", and use the .cts extension, e.g. pkg.exports["."].require.types: "./dist/types/index.d.cts" 5. pkg.exports["./loader"].import is ./loader/index.js and is written in ESM, but is interpreted as CJS. Consider using the .mjs extension, e.g. ./loader/index.mjs npx publint ./node_modules/@coveo/headless @coveo/headless lint results: Warnings: 1. pkg.exports["."].types types is interpreted as ESM when resolving with the "require" condition. This causes the types to only work when dynamically importing the package, even though the package exports CJS. Consider splitting out two "types" conditions for "import" and "require", and use the .cts extension, e.g. pkg.exports["."].require.types: "./dist/definitions/index.d.cts" ``` --- packages/atomic-react/package.json | 8 ++++---- packages/atomic-react/rollup.config.mjs | 2 +- packages/atomic/package.json | 11 ++++++----- packages/headless/esbuild.mjs | 2 +- packages/headless/package.json | 16 ++++++++-------- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/packages/atomic-react/package.json b/packages/atomic-react/package.json index a5675de0050..1da26fc2690 100644 --- a/packages/atomic-react/package.json +++ b/packages/atomic-react/package.json @@ -21,7 +21,7 @@ "promote:npm:latest": "node ../../scripts/deploy/update-npm-tag.mjs latest", "build:assets": "ncp ../atomic/dist/atomic/assets dist/assets && ncp ../atomic/dist/atomic/lang dist/lang " }, - "main": "./dist/cjs/atomic-react.js", + "main": "./dist/cjs/atomic-react.cjs", "module": "./dist/index.js", "types": "./dist/index.d.ts", "files": [ @@ -63,17 +63,17 @@ ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js", - "require": "./dist/cjs/atomic-react.js" + "require": "./dist/cjs/atomic-react.cjs" }, "./commerce": { "types": "./dist/commerce.index.d.ts", "import": "./dist/commerce.index.js", - "require": "./dist/cjs/commerce/atomic-react.js" + "require": "./dist/cjs/commerce/atomic-react.cjs" }, "./recommendation": { "types": "./dist/recommendation.index.d.ts", "import": "./dist/recommendation.index.js", - "require": "./dist/cjs/recommendation/atomic-react.js" + "require": "./dist/cjs/recommendation/atomic-react.cjs" } } } diff --git a/packages/atomic-react/rollup.config.mjs b/packages/atomic-react/rollup.config.mjs index 20e58942cdd..c525b9a58bd 100644 --- a/packages/atomic-react/rollup.config.mjs +++ b/packages/atomic-react/rollup.config.mjs @@ -97,7 +97,7 @@ const commonExternal = [ /** @returns {import('rollup').OutputOptions} */ const outputCJS = ({useCase}) => ({ - file: `dist/cjs/${useCase}atomic-react.js`, + file: `dist/cjs/${useCase}atomic-react.cjs`, format: 'cjs', }); diff --git a/packages/atomic/package.json b/packages/atomic/package.json index f9e54d00644..349dc6a9229 100644 --- a/packages/atomic/package.json +++ b/packages/atomic/package.json @@ -14,14 +14,14 @@ "types": "dist/types/index.d.ts", "exports": { "./loader": { + "types": "./loader/index.d.ts", "import": "./loader/index.js", - "require": "./loader/index.cjs.js", - "types": "./loader/index.d.ts" + "require": "./loader/index.cjs.js" }, ".": { + "types": "./dist/types/index.d.ts", "import": "./dist/index.js", - "require": "./dist/index.cjs.js", - "types": "./dist/types/index.d.ts" + "require": "./dist/index.cjs.js" }, "./themes/*": { "import": "./dist/atomic/themes/*", @@ -39,7 +39,8 @@ "files": [ "dist/", "docs/", - "licenses/" + "licenses/", + "loader/" ], "scripts": { "clean": "rimraf -rf dist/*", diff --git a/packages/headless/esbuild.mjs b/packages/headless/esbuild.mjs index f338a8a8436..87e99e222a0 100644 --- a/packages/headless/esbuild.mjs +++ b/packages/headless/esbuild.mjs @@ -210,7 +210,7 @@ async function buildBrowserConfig(options, outDir) { const nodeCjs = Object.entries(useCaseEntries).map((entry) => { const [useCase, entryPoint] = entry; const dir = getUseCaseDir('dist/', useCase); - const outfile = `${dir}/headless.js`; + const outfile = `${dir}/headless.cjs`; return buildNodeConfig( { entryPoints: [entryPoint], diff --git a/packages/headless/package.json b/packages/headless/package.json index bc217fa4844..57d26d71b2a 100644 --- a/packages/headless/package.json +++ b/packages/headless/package.json @@ -6,7 +6,7 @@ "url": "git+https://github.com/coveo/ui-kit.git", "directory": "packages/headless" }, - "main": "./dist/headless.js", + "main": "./dist/headless.cjs", "module": "./dist/headless.esm.js", "type": "module", "exports": { @@ -15,7 +15,7 @@ "node": { "types": "./dist/definitions/index.d.ts", "import": "./dist/headless.esm.js", - "require": "./dist/headless.js" + "require": "./dist/headless.cjs" }, "browser": { "types": "./dist/definitions/index.d.ts", @@ -30,7 +30,7 @@ "node": { "types": "./dist/definitions/case-assist.index.d.ts", "import": "./dist/case-assist/headless.esm.js", - "require": "./dist/case-assist/headless.js" + "require": "./dist/case-assist/headless.cjs" }, "browser": { "types": "./dist/definitions/case-assist.index.d.ts", @@ -45,7 +45,7 @@ "node": { "types": "./dist/definitions/commerce.index.d.ts", "import": "./dist/commerce/headless.esm.js", - "require": "./dist/commerce/headless.js" + "require": "./dist/commerce/headless.cjs" }, "browser": { "types": "./dist/definitions/commerce.index.d.ts", @@ -60,7 +60,7 @@ "node": { "types": "./dist/definitions/insight.index.d.ts", "import": "./dist/insight/headless.esm.js", - "require": "./dist/insight/headless.js" + "require": "./dist/insight/headless.cjs" }, "browser": { "types": "./dist/definitions/insight.index.d.ts", @@ -75,7 +75,7 @@ "node": { "types": "./dist/definitions/recommendation.index.d.ts", "import": "./dist/recommendation/headless.esm.js", - "require": "./dist/recommendation/headless.js" + "require": "./dist/recommendation/headless.cjs" }, "browser": { "types": "./dist/definitions/recommendation.index.d.ts", @@ -90,7 +90,7 @@ "node": { "types": "./dist/definitions/ssr.index.d.ts", "import": "./dist/ssr/headless.esm.js", - "require": "./dist/ssr/headless.js" + "require": "./dist/ssr/headless.cjs" }, "browser": { "types": "./dist/definitions/ssr.index.d.ts", @@ -105,7 +105,7 @@ "node": { "types": "./dist/definitions/ssr-commerce.index.d.ts", "import": "./dist/ssr-commerce/headless.esm.js", - "require": "./dist/ssr-commerce/headless.js" + "require": "./dist/ssr-commerce/headless.cjs" }, "browser": { "types": "./dist/definitions/ssr-commerce.index.d.ts",