Skip to content

Commit f377d4d

Browse files
committed
feat(esm): move to ESM in this module and in the configurations it generates
BREAKING CHANGE: You will have to be careful about file extensions - cjs/cts vs. js/ts
1 parent 39072d2 commit f377d4d

File tree

8 files changed

+3616
-198
lines changed

8 files changed

+3616
-198
lines changed

.github/workflows/npm_publish.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ jobs:
3333
- run: yarn install --immutable
3434
- run: yarn build
3535

36-
- run: npm publish --access public
36+
- name: Release
3737
env:
38-
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
39-
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
40+
run: |
41+
npm whoami
42+
yarn dlx semantic-release

.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Thumbs.db
6060
.npmignore
6161
tsconfig.json
6262
tsconfig.build.json
63-
jest.config.js
64-
.prettierrc.js
65-
.eslintrc.js
63+
.commitlintrc.json
64+
jest.config.cjs
65+
.prettierrc.cjs
66+
.eslintrc.cjs

.husky/commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx --no -- commitlint --edit ${1}

coconfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { config } from './src';
1+
import { config } from './src/index';
22

33
// During the initial creation of tsconfig. sythentic default imports are not allowed.
44
// This is here so we can handle both pre and post initial creation

package.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "@openapi-typescript-infra/coconfig",
3-
"version": "1.0.1",
3+
"version": "0.0.0",
44
"description": "Default Node.js configuration files for openapi-typescript-infra projects",
5-
"main": "build/index.js",
5+
"main": "./build/index.js",
66
"types": "build/index.d.ts",
77
"scripts": {
88
"test": "jest",
@@ -12,7 +12,8 @@
1212
"lint": "eslint .",
1313
"prepack": "pinst --disable",
1414
"postpack": "pinst --enable",
15-
"postinstall": "husky install && coconfig"
15+
"postinstall": "husky install && coconfig",
16+
"semantic-release": "semantic-release"
1617
},
1718
"engines": {
1819
"node": ">12.0.0"
@@ -21,7 +22,7 @@
2122
"license": "MIT",
2223
"repository": {
2324
"type": "git",
24-
"url": "git+https://github.com/openapi-typescript-infra/coconfig.git"
25+
"url": "https://github.com/openapi-typescript-infra/coconfig.git"
2526
},
2627
"keywords": [
2728
"typescript",
@@ -30,7 +31,12 @@
3031
"lint-staged": {
3132
"*.{js,jsx,ts,tsx}": "yarn eslint --cache --fix"
3233
},
34+
"release": {
35+
"branches": ["main"]
36+
},
3337
"devDependencies": {
38+
"@commitlint/cli": "^17.6.3",
39+
"@commitlint/config-conventional": "^17.6.3",
3440
"@types/jest": "^29.5.1",
3541
"@types/node": "^18.16.14",
3642
"@typescript-eslint/eslint-plugin": "^5.59.7",
@@ -44,6 +50,7 @@
4450
"jest": "^29.5.0",
4551
"lint-staged": "^13.2.2",
4652
"pinst": "^3.0.0",
53+
"semantic-release": "^21.0.2",
4754
"ts-jest": "^29.1.0",
4855
"ts-node": "^10.9.1",
4956
"typescript": "^5.0.4"

src/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ interface OtiCoConfig {
1414
'.npmignore': string,
1515
'tsconfig.json': CoConfigPassthroughEntry<typeof tsconfig>,
1616
'tsconfig.build.json': CoConfigPassthroughEntry<typeof tsconfigBuild>,
17-
'jest.config.js': CoConfigPassthroughEntry,
18-
'.prettierrc.js': CoConfigPassthroughEntry,
19-
'.eslintrc.js': CoConfigPassthroughEntry,
17+
'jest.config.cjs': CoConfigPassthroughEntry,
18+
'.prettierrc.cjs': CoConfigPassthroughEntry,
19+
'.eslintrc.cjs': CoConfigPassthroughEntry,
2020
'.commitlintrc.json': CoConfigPassthroughEntry,
2121
}
2222

@@ -25,8 +25,8 @@ export const config: OtiCoConfig = {
2525
'.npmignore': fs.readFileSync(path.resolve(__dirname, '../templates/npmignore'), 'utf8'),
2626
'tsconfig.json': { configuration: tsconfig, stringify: true },
2727
'tsconfig.build.json': { configuration: tsconfigBuild, stringify: true },
28-
'jest.config.js': { configuration: jestConfig },
29-
'.prettierrc.js': { configuration: prettierConfig },
30-
'.eslintrc.js': { configuration: eslintRc },
31-
'.commitlintrc.json': { configuration: commitLint },
28+
'jest.config.cjs': { configuration: jestConfig },
29+
'.prettierrc.cjs': { configuration: prettierConfig },
30+
'.eslintrc.cjs': { configuration: eslintRc },
31+
'.commitlintrc.json': { configuration: commitLint, stringify: true },
3232
};

src/tsconfig.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@ export const tsconfig = {
44
'ts-node': {
55
transpileOnly: true,
66
files: true,
7+
esm: true,
78
},
89
compilerOptions: {
910
lib: ['ES2022', 'DOM'],
10-
module: 'CommonJS',
11+
module: 'Node16',
12+
moduleResolution: 'node16',
1113
target: 'ES2022',
1214
declaration: true,
1315
sourceMap: true,
1416
outDir: './build',
1517
incremental: true,
1618
isolatedModules: true,
1719
strict: true,
18-
moduleResolution: 'NodeNext',
1920
baseUrl: './src',
2021
allowSyntheticDefaultImports: true,
2122
esModuleInterop: true,

0 commit comments

Comments
 (0)