Skip to content

Commit

Permalink
Use alternative strategy that works better for ESM builds
Browse files Browse the repository at this point in the history
Add a new top-level export map entry for `initializeProvider` that maps
correctly onto CJS and ESM builds, and add a fallback JavaScript file
at the root of the repository for build systems that don't support
export maps.

This gives the best of both worlds: build systems that support exports
will behave correctly, and those that don't will get the CJS fallback.
  • Loading branch information
Gudahtt committed Nov 27, 2024
1 parent f443329 commit 74a85e4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions initializeInpageProvider.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Re-exported for compatibility with build tools that don't support the
// `exports` field in package.json
export * from './dist/initializeInpageProvider.cjs';

Check failure on line 3 in initializeInpageProvider.d.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint

Unexpected use of file extension "cjs" for "./dist/initializeInpageProvider.cjs"
3 changes: 3 additions & 0 deletions initializeInpageProvider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Re-exported for compatibility with build tools that don't support the
// `exports` field in package.json
module.exports = require('./dist/initializeInpageProvider.cjs');

Check failure on line 3 in initializeInpageProvider.js

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint

Unexpected use of file extension "cjs" for "./dist/initializeInpageProvider.cjs"

Check failure on line 3 in initializeInpageProvider.js

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint

Unable to resolve path to module './dist/initializeInpageProvider.cjs'
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@
"default": "./dist/initializeInpageProvider.cjs"
}
},
"./dist/initializeInpageProvider.cjs": {
"types": "./dist/initializeInpageProvider.d.cts",
"default": "./dist/initializeInpageProvider.cjs"
},
"./stream-provider": {
"import": {
"types": "./dist/StreamProvider.d.mts",
Expand All @@ -70,6 +66,8 @@
"types": "./dist/index.d.cts",
"files": [
"dist",
"initializeInpageProvider.d.ts",
"initializeInpageProvider.js",
"stream-provider.js"
],
"scripts": {
Expand Down

0 comments on commit 74a85e4

Please sign in to comment.