Skip to content

Commit 2cec08e

Browse files
committed
Change to transpiled ESM
1 parent 5b2cb63 commit 2cec08e

File tree

4 files changed

+4
-9
lines changed

4 files changed

+4
-9
lines changed

.changeset/orange-files-doubt.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
'focus-trap': patch
33
---
44

5-
Fix #172 (again): Add `browser` target in package.json for use by bundlers. Both Webpack and Rollup can use this target above `module` and `main`, when specified, and our UMD bundle is transpiled down to basic ES5 for maximum browser compatibility. Our ESM bundle targets ESM browsers (which means is does not support IE 11). Webpack does this [by default](https://webpack.js.org/configuration/resolve/#resolvemainfields). Rollup, however, needs to be [configured](https://github.com/rollup/plugins/tree/master/packages/node-resolve#mainfields).
5+
Fix #172 (again): Transpile ESM bundle down to the same browser target used for the CJS and UMD bundles. ESM is just the module system, not the browser target.

README.md

-4
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ Why?
4848
Because this module uses [`EventTarget.addEventListener()`](document.createElement('button')).
4949
And its only dependency, tabbable, uses [a couple of IE9+ functions](https://github.com/davidtheclark/tabbable#browser-support).
5050

51-
> __NOTE:__ The package contains 3 entries/bundles for bundlers like Webpack and Rollup: CJS (`main`), UMD (`browser`), and ESM (`module`). Our CJS and UMD bundles are transpiled down to basic ES5 and will support IE 9+. Our ESM bundle, however, targets ESM browsers, which means it does not support IE at all because IE never supported ESM.
52-
>
53-
> Both Webpack and Rollup can use the `browser` target above `module` and `main`, when specified. Webpack does this [by default](https://webpack.js.org/configuration/resolve/#resolvemainfields). Rollup, however, needs to be [configured](https://github.com/rollup/plugins/tree/master/packages/node-resolve#mainfields).
54-
5551
## Usage
5652

5753
### createFocusTrap(element[, createOptions])

babel.config.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ module.exports = {
1414
// ESM browsers for ESM builds
1515
presets: [
1616
[
17+
// NOTE: With no targets specified, @babel/preset-env will transform all
18+
// ECMAScript 2015+ code by default, which is the original preset prior
19+
// to upgrading to Babel 7
1720
// @see https://babeljs.io/docs/en/babel-preset-env#targets
1821
'@babel/preset-env',
1922
{
2023
modules: false, // preserve ES modules
21-
targets: {
22-
esmodules: true,
23-
},
2424
},
2525
],
2626
],

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"description": "Trap focus within a DOM node.",
55
"main": "dist/focus-trap.js",
66
"module": "dist/focus-trap.esm.js",
7-
"browser": "dist/focus-trap.umd.js",
87
"types": "index.d.ts",
98
"sideEffects": false,
109
"files": [

0 commit comments

Comments
 (0)