Skip to content

Commit

Permalink
fix: TS node16 from CJS usage
Browse files Browse the repository at this point in the history
  • Loading branch information
jlp-craigmorten committed Jun 27, 2024
1 parent 465a5ce commit 4bf11fe
Show file tree
Hide file tree
Showing 4 changed files with 246 additions and 14 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,58 @@ jobs:
- run: yarn install --frozen-lockfile
- run: yarn ci

test-commonjs-example:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: yarn install --frozen-lockfile
- run: yarn install --frozen-lockfile
working-directory: ./examples/commonjs
- run: yarn test
working-directory: ./examples/commonjs

test-typescript-bundler-example:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: yarn install --frozen-lockfile
- run: yarn install --frozen-lockfile
working-directory: ./examples/typescript-bundler
- run: yarn test
working-directory: ./examples/typescript-bundler

test-typescript-legacy-example:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: yarn install --frozen-lockfile
- run: yarn install --frozen-lockfile
working-directory: ./examples/typescript-legacy
- run: yarn test
working-directory: ./examples/typescript-legacy

test-typescript-nodenext-example:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: yarn install --frozen-lockfile
- run: yarn install --frozen-lockfile
working-directory: ./examples/typescript-nodenext
- run: yarn test
working-directory: ./examples/typescript-nodenext

test-vue-example:
runs-on: ubuntu-latest
steps:
Expand Down
25 changes: 18 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@guidepup/virtual-screen-reader",
"version": "0.26.0",
"version": "0.26.1",
"description": "Virtual Screen Reader driver for unit test automation.",
"author": "Craig Morten <craig.morten@hotmail.co.uk>",
"license": "MIT",
Expand All @@ -19,18 +19,27 @@
"a11y",
"guidepup"
],
"main": "./lib/cjs/index.cjs",
"main": "./lib/cjs/index.js",
"types": "./lib/cjs/index.d.ts",
"module": "./lib/esm/index.legacy-esm.js",
"exports": {
"./package.json": "./package.json",
".": {
"types": "./lib/esm/index.d.mts",
"import": "./lib/esm/index.mjs",
"require": "./lib/cjs/index.cjs",
"default": "./lib/cjs/index.cjs"
"import": {
"types": "./lib/esm/index.d.mts",
"default": "./lib/esm/index.mjs"
},
"require": {
"types": "./lib/cjs/index.d.ts",
"default": "./lib/cjs/index.cjs"
},
"default": {
"types": "./lib/cjs/index.d.ts",
"default": "./lib/cjs/index.cjs"
}
},
"./browser.js": {
"unpkg": "./lib/esm/index.browser.js",
"browser": "./lib/esm/index.browser.js",
"import": "./lib/esm/index.browser.js",
"default": "./lib/esm/index.browser.js"
Expand All @@ -39,14 +48,15 @@
"sideEffects": false,
"scripts": {
"build": "yarn clean && yarn compile",
"ci": "yarn clean && yarn lint && yarn test:coverage && yarn build",
"ci": "yarn clean && yarn lint && yarn test:coverage && yarn build && yarn types:test",
"clean": "rimraf lib",
"compile": "tsup",
"lint": "eslint src test --cache",
"lint:fix": "yarn lint --fix",
"prepublish": "yarn build",
"test": "jest",
"test:coverage": "yarn test --coverage",
"types:test": "attw --pack . --exclude-entrypoints browser.js",
"wpt:hosts": "./test/wpt/wpt make-hosts-file | sudo tee -a /etc/hosts",
"wpt:init": "git submodule update --init --recursive",
"wpt:reset": "rimraf ./test/wpt && yarn wpt:init",
Expand All @@ -61,6 +71,7 @@
"dom-accessibility-api": "^0.6.3"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.15.3",
"@testing-library/jest-dom": "^6.4.6",
"@testing-library/react": "^16.0.0",
"@types/expect": "^24.3.0",
Expand Down
5 changes: 2 additions & 3 deletions tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { dependencies } from "./package.json";

export default defineConfig((options) => {
const commonOptions: Partial<Options> = {
clean: true,
entry: {
index: "src/index.ts",
},
Expand All @@ -17,7 +18,6 @@ export default defineConfig((options) => {
format: ["esm"],
outExtension: () => ({ js: ".mjs" }),
dts: true,
clean: true,
outDir: "./lib/esm/",
},
// Support Webpack 4 by pointing `"module"` to a file with a `.js` extension
Expand All @@ -42,6 +42,7 @@ export default defineConfig((options) => {
},
format: ["esm"],
outExtension: () => ({ js: ".js" }),
dts: true,
minify: true,
noExternal: Object.keys(dependencies),
skipNodeModulesBundle: false,
Expand All @@ -54,15 +55,13 @@ export default defineConfig((options) => {
format: ["cjs"],
outExtension: () => ({ js: ".cjs" }),
dts: true,
clean: true,
outDir: "./lib/cjs/",
},
// CJS old extension
{
...commonOptions,
format: ["cjs"],
outExtension: () => ({ js: ".js" }),
clean: true,
outDir: "./lib/cjs/",
},
] as Options[];
Expand Down
Loading

0 comments on commit 4bf11fe

Please sign in to comment.