Skip to content

Commit 81ea82f

Browse files
feat: use rollup
1 parent e37b392 commit 81ea82f

File tree

5 files changed

+165
-80
lines changed

5 files changed

+165
-80
lines changed

bin/release-ga

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22

3-
require( '../lib' ).execute().catch( error => {
3+
require( '../lib/index.cjs' ).execute().catch( error => {
44
console.error( error );
55
// eslint-disable-next-line no-magic-numbers
66
process.exit( 1 );

package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,16 @@
2929
"bin"
3030
],
3131
"scripts": {
32-
"build": "yarn install && tsc && yarn install --production",
32+
"build": "rm -rdf lib && rollup -c",
3333
"cover": "vitest run --coverage",
3434
"postinstall": "[ -n \"$CI\" ] || [ ! -f node_modules/.bin/husky ] || husky install",
3535
"lint": "eslint 'src/**/*.ts' '__tests__/**/*.ts' --cache",
3636
"lint:fix": "eslint --fix 'src/**/*.ts' '__tests__/**/*.ts'",
3737
"prepublishOnly": "[ -n \"$CI\" ] || [ ! -f node_modules/.bin/pinst ] || pinst --disable",
3838
"postpublish": "[ -n \"$CI\" ] || [ ! -f node_modules/.bin/pinst ] || pinst --enable",
3939
"release": "./bin/release-ga",
40-
"test": "yarn lint && yarn cover",
40+
"test": "yarn lint && yarn typecheck && yarn cover",
41+
"typecheck": "tsc --noEmit",
4142
"update": "npm_config_yes=true npx npm-check-updates -u --timeout 100000 && yarn install && yarn upgrade && yarn audit"
4243
},
4344
"dependencies": {
@@ -52,6 +53,11 @@
5253
"devDependencies": {
5354
"@commitlint/cli": "^16.2.3",
5455
"@commitlint/config-conventional": "^16.2.1",
56+
"@rollup/plugin-commonjs": "^21.1.0",
57+
"@rollup/plugin-json": "^4.1.0",
58+
"@rollup/plugin-node-resolve": "^13.2.1",
59+
"@rollup/plugin-typescript": "^8.3.2",
60+
"@sindresorhus/tsconfig": "^2.0.0",
5561
"@technote-space/github-action-test-helper": "^0.9.5",
5662
"@types/node": "^17.0.25",
5763
"@typescript-eslint/eslint-plugin": "^5.20.0",
@@ -62,6 +68,7 @@
6268
"husky": "^7.0.4",
6369
"lint-staged": "^12.4.0",
6470
"pinst": "^3.0.0",
71+
"rollup": "^2.70.2",
6572
"typescript": "^4.6.3",
6673
"vitest": "^0.9.4"
6774
},

rollup.config.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import pluginCommonjs from '@rollup/plugin-commonjs';
2+
import pluginJson from '@rollup/plugin-json';
3+
import pluginNodeResolve from '@rollup/plugin-node-resolve';
4+
import pluginTypescript from '@rollup/plugin-typescript';
5+
6+
export default {
7+
input: 'src/index.ts',
8+
output: {
9+
file: 'lib/index.cjs',
10+
format: 'cjs',
11+
},
12+
plugins: [
13+
pluginTypescript(),
14+
pluginNodeResolve(),
15+
pluginCommonjs(),
16+
pluginJson(),
17+
],
18+
external: [],
19+
};

tsconfig.json

Lines changed: 11 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,16 @@
11
{
2+
"extends": "@sindresorhus/tsconfig",
23
"compilerOptions": {
3-
/* Basic Options */
4-
// "incremental": true, /* Enable incremental compilation */
5-
"target": "es6",
6-
/* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
7-
"module": "commonjs",
8-
/* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
9-
// "allowJs": true, /* Allow javascript files to be compiled. */
10-
// "checkJs": true, /* Report errors in .js files. */
11-
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
12-
/* Generates corresponding '.d.ts' file. */
13-
"declaration": false,
14-
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
15-
/* Generates corresponding '.map' file. */
16-
// "sourceMap": true,
17-
// "outFile": "./", /* Concatenate and emit output to single file. */
18-
"outDir": "./lib",
19-
/* Redirect output structure to the directory. */
20-
"rootDir": "./src",
21-
/* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
22-
// "composite": true, /* Enable project compilation */
23-
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
24-
// "removeComments": true, /* Do not emit comments to output. */
25-
// "noEmit": true, /* Do not emit outputs. */
26-
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
27-
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
28-
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
29-
30-
/* Strict Type-Checking Options */
31-
"strict": true,
32-
/* Enable all strict type-checking options. */
4+
"outDir": "lib",
5+
"target": "es2020",
6+
"lib": [
7+
"es2020"
8+
],
9+
"noPropertyAccessFromIndexSignature": false,
3310
"noImplicitAny": false,
34-
/* Raise error on expressions and declarations with an implied 'any' type. */
35-
// "strictNullChecks": true, /* Enable strict null checks. */
36-
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
37-
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
38-
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
39-
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
40-
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
41-
42-
/* Additional Checks */
43-
// "noUnusedLocals": true, /* Report errors on unused locals. */
44-
// "noUnusedParameters": true, /* Report errors on unused parameters. */
45-
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
46-
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
47-
48-
/* Module Resolution Options */
49-
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
50-
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
51-
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
52-
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
53-
// "typeRoots": [], /* List of folders to include type definitions from. */
54-
// "types": [], /* Type declaration files to be included in compilation. */
55-
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
56-
"esModuleInterop": true
57-
/* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
58-
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
59-
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
60-
61-
/* Source Map Options */
62-
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
63-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
64-
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
65-
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
66-
67-
/* Experimental Options */
68-
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
69-
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
11+
"emitDeclarationOnly": true
7012
},
71-
"exclude": [
72-
"node_modules",
73-
"__tests__",
74-
"lib/**/*",
75-
"vite.config.ts"
13+
"include": [
14+
"src"
7615
]
77-
}
16+
}

0 commit comments

Comments
 (0)