Skip to content

Commit

Permalink
Fix for new tsup output
Browse files Browse the repository at this point in the history
Waiting on egoist/tsup#1053 to revert back to .d.ts extension
  • Loading branch information
timdorr committed Mar 20, 2024
1 parent f3303a8 commit 20aa126
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ jobs:
name: package
path: .

# Note: We currently expect "FalseCJS" failures for Node16 + `moduleResolution: "node16"
# Note: We currently expect "FalseESM" failures for Node16 + `moduleResolution: "node16"
- name: Run are-the-types-wrong
run: npx @arethetypeswrong/cli ./package.tgz --format table --ignore-rules false-cjs
run: npx @arethetypeswrong/cli ./package.tgz --format table --ignore-rules false-esm

test-published-artifact:
name: Test Published Artifact ${{ matrix.example }}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
],
"main": "dist/cjs/redux.cjs",
"module": "dist/redux.legacy-esm.js",
"types": "dist/redux.d.ts",
"types": "dist/redux.d.mts",
"exports": {
"./package.json": "./package.json",
".": {
"types": "./dist/redux.d.ts",
"types": "./dist/redux.d.mts",
"import": "./dist/redux.mjs",
"default": "./dist/cjs/redux.cjs"
}
Expand Down
9 changes: 5 additions & 4 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { defineConfig, Options } from 'tsup'
import type { Options } from 'tsup'
import { defineConfig } from 'tsup'

import * as babel from '@babel/core'
import { Plugin } from 'esbuild'
import type { Plugin } from 'esbuild'
import { getBuildExtensions } from 'esbuild-extra'
import fs from 'fs'

Expand Down Expand Up @@ -41,10 +42,10 @@ export default defineConfig(options => {
{
...commonOptions,
format: ['esm'],
outExtension: () => ({ js: '.mjs' }),
outExtension: () => ({ js: '.mjs' }), // Add dts: '.d.ts' when egoist/tsup#1053 lands
dts: true,
clean: true,
onSuccess() {
async onSuccess() {
// Support Webpack 4 by pointing `"module"` to a file with a `.js` extension
fs.copyFileSync('dist/redux.mjs', 'dist/redux.legacy-esm.js')
}
Expand Down

0 comments on commit 20aa126

Please sign in to comment.