From 9279cc60fa9d7a4d5b69c5b337796d6f129a5bbc Mon Sep 17 00:00:00 2001 From: Laurent Caouissin Date: Mon, 28 Oct 2024 14:54:43 +0100 Subject: [PATCH] build: fix ci and configuration of buid (esm + cjs) --- .github/workflows/ci.yaml | 10 +++------- eslint.config.js => eslint.config.mjs | 0 package.json | 18 +++++++++++------- tsconfig-esm.json | 8 ++++++++ tsconfig.build.json | 2 +- tsconfig.json | 14 ++++++-------- 6 files changed, 29 insertions(+), 23 deletions(-) rename eslint.config.js => eslint.config.mjs (100%) create mode 100644 tsconfig-esm.json diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3e879559..b4ee6781 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,13 +1,9 @@ name: ci on: push: - branches: - - main - - v1 + branches: ["main", "v1"] pull_request: - branches: - - main - - v1 + branches: ["main", "v1"] jobs: test_lint: @@ -159,7 +155,7 @@ jobs: env: XDG_CACHE_HOME: "/home/runner/.cache/yarn" - run: yarn build - - run: npx -y -p denoify@1.3.0 enable_short_npm_import_path + - run: npx -y -p denoify@1.6.13 enable_short_npm_import_path env: DRY_RUN: "0" - uses: garronej/ts-ci@v2.1.5 diff --git a/eslint.config.js b/eslint.config.mjs similarity index 100% rename from eslint.config.js rename to eslint.config.mjs diff --git a/package.json b/package.json index 511bc0da..f28e7501 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@inseefr/lunatic-dsfr", - "version": "2.4.1", + "version": "2.4.2-rc.0", "description": "Couche graphique pour Lunatic reposant sur le Système de Design de l'État (DSFR)", "repository": { "type": "git", @@ -8,12 +8,12 @@ }, "author": "INSEE (http://www.insee.fr)", "license": "MIT", - "type": "module", "main": "dist/index.js", "types": "dist/index.d.ts", + "module": "dist/esm/index.js", "scripts": { "knip": "knip", - "build": "tsc -p tsconfig.build.json", + "build": "tsc -p tsconfig.build.json && tsc -p tsconfig-esm.json", "check": "tsc --noEmit", "lint:check": "eslint ./src", "lint": "npm run lint:check -- --fix", @@ -29,11 +29,14 @@ "test": "vitest", "test:e2e": "playwright test", "test:e2e:visual": "playwright test --headed --debug e2e/pairwise.spec.ts", - "test:e2e:codegen": "playwright codegen http://localhost:6006/iframe.html?viewMode=story&id=" + "test:e2e:codegen": "playwright codegen http://localhost:6006/iframe.html?viewMode=story&id=", + "link-in-app": "tsx scripts/link-in-app.ts" }, "exports": { - ".": "./dist/index.js", - "./*": "./dist/*.js" + ".": { + "module": "./dist/esm/index.js", + "default": "./dist/index.js" + } }, "lint-staged": { "*.{ts,tsx}": [ @@ -50,7 +53,8 @@ }, "files": [ "src/", - "dist/" + "dist/", + "!dist/tsconfig.tsbuildinfo" ], "keywords": [], "homepage": "https://inseefr.github.io/Lunatic-DSFR", diff --git a/tsconfig-esm.json b/tsconfig-esm.json new file mode 100644 index 00000000..ed348818 --- /dev/null +++ b/tsconfig-esm.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.build.json", + "compilerOptions": { + "module": "es2020", + "target": "ES2018", + "outDir": "./dist/esm" + } +} diff --git a/tsconfig.build.json b/tsconfig.build.json index c16f0be5..64f72707 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -1,4 +1,4 @@ { "extends": "./tsconfig.json", - "exclude": ["src/stories/"] + "exclude": ["src/stories/", "**/*.test.ts"] } diff --git a/tsconfig.json b/tsconfig.json index d2bcc4a2..7184b671 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,25 +1,23 @@ { "compilerOptions": { - "module": "ESNext", + "module": "CommonJS", + "target": "ESNext", "moduleResolution": "node", - "target": "es5", "lib": ["ESNext", "DOM"], + "esModuleInterop": true, "declaration": true, + // Do not change or the linking script will stop working "outDir": "./dist", "sourceMap": true, "newLine": "LF", - "noUnusedLocals": true, "noUnusedParameters": true, "incremental": true, "strict": true, "downlevelIteration": true, "jsx": "react-jsx", "noFallthroughCasesInSwitch": true, - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "verbatimModuleSyntax": true, "skipLibCheck": true }, - "include": ["src"] + "include": ["src", "src/tests/setup.ts"], + "exclude": ["src/stories/", "**/*.test.ts", "src/**/*.deno.ts", "src/**/*.deno.tsx"] }