Skip to content

Support ESM #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- npm run test:react-18
- npm run test:react-17
- npm run lint
- npm run build:check
- npm run typecheck
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand Down
14 changes: 9 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,29 @@
"name": "react-use-event-hook",
"version": "0.9.2",
"description": "Same as React's `useCallback`, but returns a stable reference.",
"main": "dist/useEvent.js",
"main": "dist/cjs/useEvent.js",
"module": "dist/esm/useEvent.js",
"types": "dist/esm/useEvent.d.ts",
"files": [
"dist",
"src"
],
"scripts": {
"check": "npm run lint && npm run build:check && npm run test:react-18 && npm run test:react-17",
"check": "npm run lint && npm run typecheck && npm run test:react-18 && npm run test:react-17",
"test": "jest",
"test:react-18": "jest",
"test:react-17": "cd test/react-17; test -d node_modules || npm ci; npm run test",
"test:watch": "jest --watch",
"lint": "prettier src --check",
"lint:fix": "prettier src --write",
"build": "npm run clean && tsc",
"build": "npm run clean && npm run build:esm && npm run build:cjs",
"build:esm": "tsc",
"build:cjs": "tsc --outDir dist/cjs --module commonjs",
"clean": "rimraf dist",
"build:watch": "tsc --watch",
"build:check": "tsc --noEmit",
"typecheck": "tsc --noEmit",
"prepublishOnly": "npm run build",
"preversion": "npm run test && npm run build:check"
"preversion": "npm run test && npm run typecheck"
},
"repository": {
"type": "git",
Expand Down
11 changes: 6 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "ES5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
"target": "ES2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "ES2020", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
Expand All @@ -14,7 +14,7 @@
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
"sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "dist", /* Redirect output structure to the directory. */
"outDir": "dist/esm", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
Expand Down Expand Up @@ -52,7 +52,7 @@
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
"resolveJsonModule": true,
// "resolveJsonModule": true,

/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
Expand All @@ -69,6 +69,7 @@
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
},
"exclude": [
"**/*.test.*"
"**/*.test*",
"dist/**"
]
}