From 472a59ca8c37d7398377757956cac92eeebf2cad Mon Sep 17 00:00:00 2001 From: Ruslan Lopatin Date: Fri, 27 Jan 2023 18:22:28 +0700 Subject: [PATCH] Build with `@run-z/project-config` --- .eslintrc.cjs | 4 +-- .github/workflows/build.yml | 2 ++ .gitignore | 6 ++--- .npmignore | 17 ++++++++----- LICENSE | 2 +- jest.config.js | 49 +++---------------------------------- package.json | 30 ++++++++++++----------- rollup.config.js | 41 ------------------------------- tsconfig.json | 20 ++++----------- tsconfig.main.json | 5 ---- tsconfig.spec.json | 10 -------- typedoc.json | 3 +-- 12 files changed, 45 insertions(+), 144 deletions(-) delete mode 100644 rollup.config.js delete mode 100644 tsconfig.main.json delete mode 100644 tsconfig.spec.json diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 964e675..28a9213 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,6 +1,6 @@ module.exports = { root: true, - ignorePatterns: ['node_modules/', 'dist/', 'target/', 'd.ts/', '*.d.ts'], + ignorePatterns: ['node_modules/', 'dist/', 'target/'], extends: ['@run-z'], overrides: [ { @@ -26,7 +26,7 @@ module.exports = { extends: ['@run-z/eslint-config/jest'], parserOptions: { tsconfigRootDir: __dirname, - project: './tsconfig.spec.json', + project: './tsconfig.json', }, }, ], diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0786741..3254592 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,6 +40,8 @@ jobs: run: pnpm install - name: Build the project + env: + RUNZ_TEST_RUNNER: ts-jest run: pnpm ci:all - name: Upload coverage report diff --git a/.gitignore b/.gitignore index 8e72ff0..88bb188 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # Node.js modules -node_modules +node_modules/ # IntelliJ IDEA files .idea @@ -23,10 +23,10 @@ pnpm-lock.yaml *.tgz # Intermediate files -/target +/target/ # Distribution directory -/dist +/dist/ # Type definitions *.d.ts diff --git a/.npmignore b/.npmignore index 3605956..3ea7bf8 100644 --- a/.npmignore +++ b/.npmignore @@ -1,21 +1,20 @@ # Node.js modules -node_modules +node_modules/ # IntelliJ IDEA files .idea *.iml # Intermediate files -/target +/target/ # Logs *.log # Package archives -*.tgz # Source files -/src +/src/ # Build scripts /build @@ -25,12 +24,18 @@ node_modules /*.cjs /*.js /*.json +/*.mjs # Package lock -/yarn.lock +yarn.lock +package-lock.json +pnpm-lock.yaml # Include distribution dir -!/dist +!/dist/ + +# Package archive +*.tgz # Include type definitions !*.d.ts diff --git a/LICENSE b/LICENSE index ab07d43..4bc3706 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018-2022 Ruslan Lopatin +Copyright (c) 2018-2023 Ruslan Lopatin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/jest.config.js b/jest.config.js index 870a9a7..7a941ff 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,47 +1,6 @@ -export default { - preset: 'ts-jest/presets/default-esm', - collectCoverage: true, - collectCoverageFrom: [ - 'src/**/*.ts', - '!src/spec/**/*.ts', - '!src/**/*.spec.ts', - '!src/**/index.ts', - '!src/**/main.ts', - '!**/node_modules/**', - ], - coverageDirectory: 'target/coverage', - coverageThreshold: { - global: { - statements: 100, - branches: 100, - functions: 100, - lines: 100, - }, - }, - extensionsToTreatAsEsm: ['.ts'], - reporters: [ - 'default', - [ - 'jest-junit', - { - suiteName: '@wesib/css', - outputDirectory: './target/test-results', - classNameTemplate: '{classname}: {title}', - titleTemplate: '{classname}: {title}', - ancestorSeparator: ' › ', - usePathForSuiteName: 'true', - }, - ], - ], +import { configureJest } from '@run-z/project-config'; + +export default await configureJest({ restoreMocks: true, testEnvironment: 'jsdom', - transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: 'tsconfig.spec.json', - useESM: true, - }, - ], - }, -}; +}); diff --git a/package.json b/package.json index 5d4a9da..9e70056 100644 --- a/package.json +++ b/package.json @@ -18,13 +18,15 @@ "url": "https://github.com/wesib/css/issues" }, "type": "module", - "main": "./dist/wesib.css.js", - "types": "./index.d.ts", - "exports": "./dist/wesib.css.js", + "types": "./dist/wesib-css.d.ts", + "exports": { + "types": "./dist/wesib-css.d.ts", + "default": "./dist/wesib-css.js" + }, "peerDependencies": { "@frontmeans/style-producer": "^7.0.1", - "@proc7ts/fun-events": "^10.5.1", - "@wesib/wesib": "^2.0.1" + "@proc7ts/fun-events": "^10.5.2", + "@wesib/wesib": "^2.0.2" }, "dependencies": { "@frontmeans/dom-primitives": "^1.1.0", @@ -44,10 +46,13 @@ "@proc7ts/context-builder": "^7.0.1", "@proc7ts/fun-events": "^10.5.2", "@run-z/eslint-config": "^3.3.1", - "@run-z/rollup-helpers": "^2.1.0", + "@run-z/prettier-config": "^2.0.0", + "@run-z/project-config": "^0.15.0", + "@swc/core": "^1.3.29", + "@swc/jest": "^0.2.24", "@typescript-eslint/eslint-plugin": "^5.49.0", "@typescript-eslint/parser": "^5.49.0", - "@wesib/wesib": "^2.0.1", + "@wesib/wesib": "^2.0.2", "eslint": "^8.32.0", "eslint-plugin-jest": "^27.2.1", "gh-pages": "^5.0.0", @@ -58,10 +63,7 @@ "prettier": "^2.8.3", "prettier-eslint-cli": "^7.1.0", "rollup": "^3.11.0", - "rollup-plugin-flat-dts": "^2.0.2", - "rollup-plugin-typescript2": "^0.34.1", "run-z": "^1.11.0", - "shx": "^0.3.4", "ts-jest": "^29.0.5", "tslib": "^2.5.0", "typedoc": "^0.23.24", @@ -69,14 +71,14 @@ }, "scripts": { "all": "run-z build,lint,test", - "build": "run-z +z --then rollup -c", + "build": "run-z +z --then build-z", "ci:all": "run-z all +test/--ci/--runInBand", - "clean": "run-z +z --then shx rm -rf \"index.d.ts?(.map)\" \"*/index.d.ts?(.map)\" dist target", + "clean": "run-z +z --then clean-z", "doc": "run-z +z --then typedoc", "doc:publish": "run-z doc --then gh-pages --dist target/typedoc --dotfiles", "format": "run-z +z --then prettier-eslint --write --include-dot-files \"src/**/*.*\" \"*.{js,cjs,json,md}\"", "lint": "run-z +z --then eslint .", - "test": "run-z +z env:NODE_OPTIONS=\"--experimental-vm-modules --no-warnings\" --then jest", - "z": "run-z +cmd:rollup,+cmd:typedoc,+cmd:eslint,+cmd:jest" + "test": "run-z +z env:NODE_OPTIONS=\"--experimental-vm-modules --no-warnings\" --then test-z", + "z": "run-z +cmd:build-z,+cmd:typedoc,+cmd:eslint,+cmd:test-z" } } diff --git a/rollup.config.js b/rollup.config.js deleted file mode 100644 index 4ed317e..0000000 --- a/rollup.config.js +++ /dev/null @@ -1,41 +0,0 @@ -import { externalModules } from '@run-z/rollup-helpers'; -import { defineConfig } from 'rollup'; -import flatDts from 'rollup-plugin-flat-dts'; -import ts from 'rollup-plugin-typescript2'; -import typescript from 'typescript'; - -export default defineConfig({ - input: { - 'wesib.css': './src/index.ts', - }, - plugins: [ - ts({ - typescript, - tsconfig: 'tsconfig.main.json', - cacheRoot: 'target/.rts2_cache', - useTsconfigDeclarationDir: true, - }), - ], - external: externalModules(), - treeshake: { - moduleSideEffects: false, - }, - output: { - format: 'esm', - sourcemap: true, - dir: '.', - entryFileNames: 'dist/[name].js', - chunkFileNames: 'dist/_[name].js', - hoistTransitiveImports: false, - plugins: [ - flatDts({ - tsconfig: 'tsconfig.main.json', - lib: true, - compilerOptions: { - declarationMap: true, - }, - internal: ['**/impl/**', '**/*.impl'], - }), - ], - }, -}); diff --git a/tsconfig.json b/tsconfig.json index 3a0b912..78ebb15 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,23 +1,13 @@ { + "extends": "@run-z/project-config/tsconfig.lib.json", "compilerOptions": { - "moduleResolution": "Node", - "module": "ES2015", - "target": "ES2019", - "strict": true, "experimentalDecorators": true, - "noFallthroughCasesInSwitch": true, - "noImplicitOverride": true, - "noImplicitReturns": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "forceConsistentCasingInFileNames": true, - "importHelpers": true, - "noEmitHelpers": true, "lib": ["DOM", "ES2019"], - "types": [], + "module": "ES2015", + "moduleResolution": "Node", "outDir": "target/js", - "sourceMap": true, - "newLine": "LF" + "target": "ES2019", + "types": [] }, "include": ["src/**/*"] } diff --git a/tsconfig.main.json b/tsconfig.main.json deleted file mode 100644 index 5a53c65..0000000 --- a/tsconfig.main.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": "./tsconfig.json", - "files": ["./src/index.ts"], - "include": [] -} diff --git a/tsconfig.spec.json b/tsconfig.spec.json deleted file mode 100644 index 2d23de1..0000000 --- a/tsconfig.spec.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "esModuleInterop": true, - "noUnusedLocals": false, - "noUnusedParameters": false, - "importHelpers": false, - "noEmitHelpers": false - } -} diff --git a/typedoc.json b/typedoc.json index 5b71731..371d996 100644 --- a/typedoc.json +++ b/typedoc.json @@ -1,6 +1,5 @@ { "entryPoints": ["src/index.ts"], "name": "Wesib: CSS Producer", - "out": "./target/typedoc", - "tsconfig": "tsconfig.main.json" + "out": "./target/typedoc" }