Skip to content

Commit

Permalink
perf: optimized build config
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurfiorette committed Mar 11, 2022
1 parent 6fd42b2 commit 3a800d7
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
run: yarn build

- name: ESCheck
run: yarn check
run: yarn run check

- name: Publish to Codecov
uses: codecov/[email protected]
Expand Down
4 changes: 2 additions & 2 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -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']
});
3 changes: 2 additions & 1 deletion build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 14 additions & 8 deletions build/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
if [ $? -eq 1 ]; then
exit 1
fi

# :)
8 changes: 6 additions & 2 deletions build/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"]
}
2 changes: 2 additions & 0 deletions build/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/**
Expand Down Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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"]
}

0 comments on commit 3a800d7

Please sign in to comment.