Skip to content

Commit 556dc22

Browse files
committed
build(hybrid)!: esm-cjs hybrid migration
- drop `.js` extensions - drop support for `esm2015` and `esm5` build outputs - remove `browser`, `es2015`, and `umd` package entrypoints - update bundle filenames and locations
1 parent 690279d commit 556dc22

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2277
-2966
lines changed

commitlint.config.js renamed to .commitlintrc.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
1-
require('ts-node').register(require('./tsconfig.json'))
2-
require('tsconfig-paths/register')
3-
4-
const workspaces = require('./tools/helpers/workspaces').default
1+
import type { UserConfig } from '@commitlint/types'
2+
import workspaces from './tools/helpers/workspaces'
53

64
/**
75
* @file Commitlint Configuration
86
* @see https://commitlint.js.org/#/guides-local-setup
97
* @see https://commitlint.js.org/#/reference-configuration
108
*/
119

12-
module.exports = {
10+
const config: UserConfig = {
1311
/**
1412
* Enable default ignore rules.
1513
*/
1614
defaultIgnores: true,
1715

1816
/**
19-
* IDs of commitlint configurations.
17+
* IDs of commitlint configurations to extend.
2018
*/
2119
extends: ['@commitlint/config-conventional'],
2220

@@ -48,12 +46,17 @@ module.exports = {
4846
2,
4947
'always',
5048
[
49+
'cjs',
5150
'deploy',
5251
'deps',
5352
'deps-dev',
53+
'deps-opt',
5454
'deps-peer',
55+
'esm',
5556
'github',
57+
'hybrid',
5658
'release',
59+
'scripts',
5760
'tests',
5861
'tools',
5962
'typescript',
@@ -90,3 +93,5 @@ module.exports = {
9093
]
9194
}
9295
}
96+
97+
export default config

.env

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,36 @@
11
# Environment Variables - Project Defaults
2-
#
2+
#
33
# References:
4-
#
5-
# - https://github.com/entropitor/dotenv-cli
4+
#
5+
# - https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/dotenv
66

77
DEBUG='*,-babel*,-yarn,-eslint:*,-eslintrc:*,-lint-staged:*,-typescript-eslint*'
88
DEBUG_COLORS=true
9-
NPM_TOKEN=$NPM_TOKEN_FLDV
9+
GITHUB_WORKSPACE=$PWD
1010
NODE_ENV=development
11+
# Fixes `YN0000: Strings should avoid referencing the node_modules directory`
12+
# warning during the `yarn check:install` lifecycle
13+
NODE_MODULES=node_modules
14+
NPM_TOKEN=$NPM_TOKEN_FLDV
1115
PAT_GPR=$PAT_GPR_FLDV
12-
PAT_GPR_REPO_ADMIN=$PAT_REPO_FLDV_ADMIN
13-
TS_NODE_PROJECT="$PWD/tsconfig.json"
16+
PROJECT_CWD=$GITHUB_WORKSPACE
17+
18+
# NODE_OPTIONS - Use ESM
19+
# See: https://github.com/TypeStrong/ts-node/issues/1007
20+
if [ -f "./node_modules/ts-node/esm.mjs" ]; then
21+
# Silence warnings
22+
NODE_NO_WARNINGS=1
23+
24+
# Import JSON modules
25+
JSON_MODULES=''
26+
[ !$GITHUB_ACTIONS ] && JSON_MODULES='--experimental-json-modules'
27+
28+
# Don't require imported modules to include extensions
29+
SPECIFIER_RESOLUTION='--es-module-specifier-resolution node'
30+
31+
# Use custom ESM loader
32+
LOADER="--loader $PROJECT_CWD/tools/loaders/esm.mjs"
33+
34+
# Specify Node options
35+
NODE_OPTIONS="$JSON_MODULES $SPECIFIER_RESOLUTION $LOADER"
36+
fi

.env.production

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
# Environment Variables - Project - `production`
2-
#
3-
# References:
4-
#
5-
# - https://github.com/entropitor/dotenv-cli
62

73
NODE_ENV=production
8-
TS_NODE_PROJECT="$PWD/tsconfig.prod.json"

.env.test

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
# Environment Variables - Project - `test`
2-
#
3-
# References:
4-
#
5-
# - https://github.com/entropitor/dotenv-cli
62

73
NODE_ENV=test
8-
TS_NODE_PROJECT="$PWD/tsconfig.test.json"

.eslintignore

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# ESLint Ignore
22
# https://eslint.org/docs/user-guide/configuring#ignoring-files-and-directories
33

4-
.yarn/
5-
coverage/
6-
node_modules/
4+
**/coverage/*
5+
**/node_modules/*
6+
7+
.yarn/*
78
packages/*/build/
8-
packages/*/cjs/
9-
packages/*/dist/
10-
packages/*/esm5/
11-
packages/*/esm2015/
12-
packages/*/types/
9+
packages/*/cjs/*
10+
packages/*/esm/*
11+
packages/*/types/*
12+
13+
**/CHANGELOG.md
14+
15+
!packages/src/types/*

.eslintrc.base.js renamed to .eslintrc.base.cjs

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const prettierConfig = require('./.prettierrc')
2-
31
/**
42
* @file ESLint Configuration - Base
53
* @see https://eslint.org/docs/user-guide/configuring
@@ -26,7 +24,7 @@ module.exports = {
2624
impliedStrict: true,
2725
jsx: true
2826
},
29-
extraFileExtensions: ['cjs'],
27+
extraFileExtensions: ['.cjs', '.mjs'],
3028
project: ['./packages/**/tsconfig.json', './tsconfig.json'],
3129
sourceType: 'module',
3230
tsconfigRootDir: __dirname,
@@ -87,7 +85,7 @@ module.exports = {
8785
],
8886
'no-ex-assign': 0,
8987
'prefer-arrow-callback': 2,
90-
'prettier/prettier': [2, prettierConfig],
88+
'prettier/prettier': [2, require('./.prettierrc.cjs')],
9189
'sort-keys': [
9290
1,
9391
'asc',
@@ -116,16 +114,21 @@ module.exports = {
116114
skipWordIfMatch: [],
117115
skipWords: [
118116
'argv',
117+
'basedir',
119118
'bundlers',
120119
'cjs',
121120
'commitlint',
121+
'commonjs',
122122
'cmd',
123123
'dotenv',
124124
'enum',
125125
'esm',
126-
'esm5',
126+
'extensionless',
127127
'formatter',
128+
'loadenv',
129+
'mjs',
128130
'perf',
131+
'pkgfile',
129132
'pnv',
130133
'postinstall',
131134
'prepack',
@@ -134,14 +137,17 @@ module.exports = {
134137
'stderr',
135138
'stdout',
136139
'tgz',
140+
'tsc',
137141
'tsconfig',
138142
'ttsc',
139143
'typeof',
140144
'umd',
141145
'usr',
146+
'wasm',
142147
'wip',
143148
'workspace',
144-
'workspaces'
149+
'workspaces',
150+
'yargs'
145151
],
146152
strings: true
147153
}
@@ -220,31 +226,34 @@ module.exports = {
220226
},
221227
overrides: [
222228
{
223-
files: ['**/*.cjs', '**/*.js', '**/*.md/*.js'],
224-
parser: `${__dirname}/node_modules/@babel/eslint-parser/lib/index.cjs`,
225-
parserOptions: {
226-
requireConfigFile: false
227-
},
229+
files: ['**/*.cjs'],
228230
rules: {
229-
'@typescript-eslint/explicit-module-boundary-types': 0,
230-
'@typescript-eslint/no-var-requires': 0
231+
'unicorn/prefer-module': 0
231232
}
232233
},
233234
{
234-
files: ['**/*.cjs', '*.js'],
235+
files: ['**/*.cjs', '**/*.md/*.js'],
235236
rules: {
236-
'unicorn/prefer-module': 0
237+
'@typescript-eslint/no-var-requires': 0
238+
}
239+
},
240+
{
241+
files: ['**/*.cjs', '**/*.mjs'],
242+
parser: `${__dirname}/node_modules/@babel/eslint-parser/lib/index.cjs`,
243+
parserOptions: {
244+
requireConfigFile: false
237245
}
238246
},
239247
{
240248
files: ['**/*.md'],
249+
extends: ['plugin:markdownlint/recommended'],
250+
parser: require.resolve('eslint-plugin-markdownlint/parser'),
241251
processor: 'markdown/markdown'
242252
},
243253
{
244254
files: ['**/*.md/*.ts'],
245255
parser: require.resolve('@typescript-eslint/parser')
246256
},
247-
248257
{
249258
files: ['**/*.spec.ts'],
250259
env: {
@@ -273,7 +282,7 @@ module.exports = {
273282
}
274283
},
275284
{
276-
files: ['**/__mocks__/**', '**/__tests__/**', '**/tools/**', '*.js'],
285+
files: ['**/__mocks__/**', '**/__tests__/**', '**/tools/**'],
277286
rules: {
278287
'tree-shaking/no-side-effects-in-initialization': 0
279288
}
@@ -285,6 +294,12 @@ module.exports = {
285294
'@typescript-eslint/triple-slash-reference': 0,
286295
'unicorn/filename-case': 0
287296
}
297+
},
298+
{
299+
files: ['tools/loaders/env.cjs'],
300+
rules: {
301+
'unicorn/no-array-reduce': 0
302+
}
288303
}
289304
],
290305
settings: {

.eslintrc.js renamed to .eslintrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55

66
module.exports = {
77
root: true,
8-
extends: ['./.eslintrc.base']
8+
extends: ['./.eslintrc.base.cjs']
99
}

0 commit comments

Comments
 (0)