-
-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add new export for
initializeInpageProvider
(#391)
* feat: Add subpath export for `initializeInpageProvider.cjs` Add a subpath export for the `initializeInpageProvider.cjs` file. This allows projects with legacy build systems to import this file directly, which can be useful for reducing bundle size (especially for build systems without tree shaking). The `metamask-extension` project uses two build systems: one which obeys export maps, one which ignores them (Webpack and browserify respectively). The existing `initializeInpageProvider` export map entry doesn't work for browserify because it's looking for `initializeInpageProvider.js`. The file extension is wrong. * Use alternative strategy that works better for ESM builds 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
Showing
4 changed files
with
23 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* eslint-disable import/extensions */ | ||
|
||
// Re-exported for compatibility with build tools that don't support the | ||
// `exports` field in package.json | ||
export * from './dist/initializeInpageProvider.cjs'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* eslint-disable import/extensions,import/no-unresolved */ | ||
|
||
// Re-exported for compatibility with build tools that don't support the | ||
// `exports` field in package.json | ||
module.exports = require('./dist/initializeInpageProvider.cjs'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters