Skip to content

Commit

Permalink
fix errors (#4444)
Browse files Browse the repository at this point in the history
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"
```
  • Loading branch information
alexprudhomme authored Sep 20, 2024
1 parent 2207b51 commit 015040f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
8 changes: 4 additions & 4 deletions packages/atomic-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -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"
}
}
}
2 changes: 1 addition & 1 deletion packages/atomic-react/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});

Expand Down
11 changes: 6 additions & 5 deletions packages/atomic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/*",
Expand All @@ -39,7 +39,8 @@
"files": [
"dist/",
"docs/",
"licenses/"
"licenses/",
"loader/"
],
"scripts": {
"clean": "rimraf -rf dist/*",
Expand Down
2 changes: 1 addition & 1 deletion packages/headless/esbuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
16 changes: 8 additions & 8 deletions packages/headless/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit 015040f

Please sign in to comment.