Skip to content

Commit

Permalink
build(package): enhance build configuration
Browse files Browse the repository at this point in the history
- enhance build configuration: add new configuration for library export
- change test runner: jest > vitest
- change package manager: npm > pnpm
  • Loading branch information
imjuni committed Apr 7, 2024
1 parent 64b8126 commit 86d0420
Show file tree
Hide file tree
Showing 27 changed files with 7,562 additions and 12,630 deletions.
162 changes: 122 additions & 40 deletions .configs/.ctirc
Original file line number Diff line number Diff line change
@@ -1,42 +1,124 @@
{
// common configuration
// tsconfig.json path: you must pass path with filename, like this "./tsconfig.json"
"project": "./tsconfig.json",

// Export filename, if you not pass this field that use "index.ts" or "index.d.ts"
"exportFilename": "index.ts",

// create, single command configuration
// add ctix comment at first line of creted index.ts file, that remark created from ctix
"useSemicolon": true,

// timestamp write on ctix comment right-side, only works in useComment option set true
"useTimestamp": false,

// add ctix comment at first line of creted index.ts file, that remark created from ctix
"useComment": false,

// quote mark " or '
"quote": "'",

// overwrite index.ts file also index.ts file already exist that create backup file
"overwrite": true,

// keep file extension in export statement path
"keepFileExt": false,

// only create command configuration
// If set true this option, skip empty directory
"skipEmptyDir": true,

// only single command configuration
// Output directory. It works only single mode.
"output": "./src",

// Use rootDir or rootDirs configuration in tsconfig.json.
"useRootDir": false,

// only remove command configuration
// remove with backup file
"includeBackup": true
// Stream of cli spinner, you can pass stdout or stderr
//
// @mode all
// @default stdout
"spinnerStream": "stdout",

// Stream of cli progress, you can pass stdout or stderr
//
// @mode all
// @default stdout
"progressStream": "stdout",

// Stream of cli reasoner. Reasoner show name conflict error and already exist index.ts file error.
// You can pass stdout or stderr
//
// @mode all
// @default stderr
"reasonerStream": "stderr",

"options": [
{
// build mode
// - create: create an `index.ts` file in each directory
// - bundle: bundle all export information in one `index.ts` file
"mode": "bundle",

// tsconfig.json path: you must pass path with filename, like this "./tsconfig.json"
// only work root directory or cli parameter
//
// @mode all
"project": "tsconfig.json",

// Export filename, if you not pass this field that use "index.ts" or "index.d.ts"
//
// @mode create, bundle, remove
// @default index.ts
"exportFilename": "index.ts",

// add ctix comment at first line of creted index.ts file, that remark created from ctix
//
// @mode create, bundle
// @default false
"useSemicolon": true,

// add ctix comment at first line of creted index.ts file, that remark created from ctix
//
// @mode create, bundle
// @default false
"useBanner": false,

// If specified as true, adds the created date to the top of the `index.ts` file,
// this option only works if the `useBanner` option is enabled
//
// @mode create, bundle
// @default false
"useTimestamp": false,

// quote mark " or '
// @mode create, bundle
//
// @default '
"quote": "'",

// Use to add a literal like `"use strict"` to the top. It will be added before the banner.
//
// @mode create, bundle
"directive": "",

// keep file extension in export statement path
//
// if this option set true that see below
// export * from './test.ts'
//
// @mode create, bundle
// @default none
"fileExt": "none",

// overwrite each index.ts file
// @mode create, bundle
// @default false
"overwrite": false,

// Create a backup file if the `index.ts` file already exists.
// This option only works if the `overwrite` option is enabled.
//
// @mode create, bundle
// @defulat true
"backup": true,

// When generating the `index.ts` file, decide how you want to generate it
//
// @mode create, bundle
// @default auto
"generationStyle": "auto",

// A list of files to use when generating the index.ts file. If no value is set,
// the value of the include setting set in the tsconfig.json file will be used
//
// @mode create, bundle
"include": ["src/**/*.ts"],

// A list of files to exclude when generating the index.ts file. If no value is set,
// the value of the exclude setting set in the tsconfig.json file is used
//
// @mode create, bundle
"exclude": ["examples/**/*", "dist/**", ".configs/**", "src/test-tools/**/*", "**/__tests__/**"],

// Output directory. Default value is same project directory
// @mode bundle
"output": "src",

// remove with backup file
// @mode remove
// @default false
"removeBackup": true,

// answer `yes` to all questions
// @mode remove
// @default false
"forceYes": true
}
]
}
28 changes: 28 additions & 0 deletions .configs/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { nodeResolve } from '@rollup/plugin-node-resolve';
import readPackage from 'read-pkg';
import { dts } from 'rollup-plugin-dts';

const pkg = readPackage.sync();

const resolveOnly = (module) => {
return (
pkg?.dependencies?.[module] != null &&
pkg?.devDependencies?.[module] != null &&
pkg?.peerDependencies?.[module] != null
);
};

const config = [
{
input: 'dist/types/origin/index.d.ts',
output: [{ file: 'dist/types/index.d.ts', format: 'esm' }],
plugins: [
nodeResolve({ resolveOnly }),
dts({
tsconfig: './tsconfig.dts.json',
}),
],
},
];

export default config;
11 changes: 0 additions & 11 deletions .configs/rollup.mjs

This file was deleted.

2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
es6: true,
node: true,
},
ignorePatterns: ['__test__/*', '__tests__/*', 'examples/*', 'coverage/*', 'dist/*'],
ignorePatterns: ['__test__/*', '__tests__/*', 'examples/*', 'coverage/*', 'dist/*', 'vitest.config.ts'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.eslint.json',
Expand Down
43 changes: 39 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,46 @@
"version": "0.2.0",
"configurations": [
{
"name": "Attach",
"port": 9229,
"request": "attach",
"name": "Jest",
"request": "launch",
"runtimeArgs": ["run-script", "test:debug", "${input:testPath}"],
"runtimeExecutable": "npm",
"skipFiles": ["<node_internals>/**"],
"type": "pwa-node"
"stopOnEntry": true,
"type": "node"
},
{
"type": "node",
"request": "launch",
"name": "Launch Test",
"args": ["--runInBand", "--no-cache", "${input:testPath}"],
"runtimeArgs": ["-r", "ts-node/register", "--inspect"],
"stopOnEntry": false,
"sourceMaps": true,
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
"env": {
"TS_NODE_PROJECT": "tsconfig.json"
}
},
{
"type": "node",
"request": "attach",
"name": "Attach Process",
"port": 9229
}
],
"inputs": [
{
"type": "promptString",
"id": "testPath",
"description": "Path Name your testcase",
"default": ""
},
{
"type": "promptString",
"id": "testName",
"description": "Name your testcase",
"default": ""
}
]
}
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
"dist": true
},
"files.associations": {
".depsdiffrc": "jsonc",
".ctirc": "jsonc",
".erdiarc": "jsonc",
"typedoc.json": "jsonc"
},
Expand Down
Loading

0 comments on commit 86d0420

Please sign in to comment.