diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1923892..7ad1cf4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: run: yarn build - name: ESCheck - run: yarn check + run: yarn run check - name: Publish to Codecov uses: codecov/codecov-action@v2.1.0 diff --git a/.prettierrc.js b/.prettierrc.js index b50fa93..9f0de09 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -1,6 +1,6 @@ // https://github.com/arthurfiorette/prettier-config module.exports = require('@arthurfiorette/prettier-config')({ - tsdoc: true - // plugins: ['prettier-plugin-organize-imports', 'prettier-plugin-jsdoc'] + tsdoc: true, + plugins: ['prettier-plugin-organize-imports', 'prettier-plugin-jsdoc'] }); diff --git a/build/build.sh b/build/build.sh index 7ab7bf1..6152cf8 100644 --- a/build/build.sh +++ b/build/build.sh @@ -14,7 +14,8 @@ webpack --config build/webpack.config.js & tsc -p build/tsconfig.types.json & # Add a simple index.d.ts file to type all dev builds -echo "export * from '../dist/index.d.ts';" | tee dev/index.d.ts > /dev/null & +echo "export * from '../dist/index';" | tee dev/index.d.ts > /dev/null & +echo "export * from './index';" | tee dist/index.umd.d.ts > /dev/null & wait diff --git a/build/check.sh b/build/check.sh index e8c600d..5b5dd54 100644 --- a/build/check.sh +++ b/build/check.sh @@ -3,16 +3,22 @@ # This script is used to check the umd's ecmascript compatibility. # It is intended to be run from the project's root directory. -echo "\nStarting checking...\n" +yarn es-check es2017 dist/index.cjs dev/index.cjs dev/index.umd.js -es-check es2015 umd/es5.js & +if [ $? -eq 1 ]; then + exit 1 +fi -es-check es2017 umd/index.js cjs/index.js & -es-check es2017 esm/index.js --module & +yarn es-check es2017 dist/index.mjs dev/index.mjs --module -es-check es2020 dev/index.umd.js dev/index.cjs & -es-check es2020 dev/index.mjs --module & +if [ $? -eq 1 ]; then + exit 1 +fi -wait +yarn es-check es5 dist/index.umd.js -echo "\nCheck done!" \ No newline at end of file +if [ $? -eq 1 ]; then + exit 1 +fi + +# :) \ No newline at end of file diff --git a/build/tsconfig.build.json b/build/tsconfig.build.json index dc5de4f..29d0d63 100644 --- a/build/tsconfig.build.json +++ b/build/tsconfig.build.json @@ -1,7 +1,8 @@ { "extends": "../tsconfig.json", "compilerOptions": { - "module": "ESNext", // webpack converts to UMD + // webpack converts to UMD or CJS if needed + "module": "ESNext", "target": "ESNext", // Emits all import helpers as an import to tslib @@ -10,7 +11,10 @@ // No declaration "declaration": false, - "declarationMap": false + "declarationMap": false, + + // This allow us to import javascript files from node_modules. + "allowJs": true }, "include": ["../src"] } diff --git a/build/webpack.config.js b/build/webpack.config.js index 40e44eb..8d71123 100644 --- a/build/webpack.config.js +++ b/build/webpack.config.js @@ -5,6 +5,7 @@ const path = require('path'); const TerserWebpackPlugin = require('terser-webpack-plugin'); const { DefinePlugin } = require('webpack'); +/** @type {(...args: string[]) => string} */ const root = (...p) => path.resolve(__dirname, '..', ...p); /** @@ -60,6 +61,7 @@ const config = ({ module: { rules: [ { + // Include node_modules to parse all javascript files imported include: /src|node_modules/, test: /\.(ts|js)$/, loader: 'ts-loader', diff --git a/tsconfig.json b/tsconfig.json index fc56ac8..80ff61c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,7 @@ /* Projects */ "incremental": true /* Enable incremental compilation */, // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */ + "tsBuildInfoFile": "./node_modules/ts-info.json", /* Specify the folder for .tsbuildinfo incremental compilation files. */ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ @@ -97,5 +97,5 @@ "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ "skipLibCheck": true /* Skip type checking all .d.ts files. */ }, - "include": ["src", "test", "examples", "docs"] + "include": ["src", "test", "examples", "docs", "build"] }