From 30b79bee2f83b76a1ebd21066e2cd233f6697b19 Mon Sep 17 00:00:00 2001 From: Jacob Ketcheson Date: Wed, 12 Oct 2022 10:07:52 -0600 Subject: [PATCH] feat!: raises the target floor for compiled Javascript to ES6 BREAKING CHANGE All evergreen browsers fully support the ES6 spec (Even Safari as of Safari 10) Generating ES5 compliant code introduces unnecessary language polyfills that can bloat bundles and possibly create warnings in rollup (no top level this for example). Since this library supports React 18 and React 18 no longer supports IE 11 this seems like a good time to raise the floor of the non-ESNext generated code. If users of this library need to support IE 11 still they can always include this library in their babel config to transpile it down to whatever ES version they need to support. --- README.md | 4 ++-- package.json | 4 ++-- src/__docs__/Introduction.story.mdx | 4 ++-- tsconfig.build.json | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index bbf893112..229522504 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,8 @@ transpile your `node-modules` in order to run in IE. This package provides three levels of compilation: 1. **Main**, the `/cjs` folder — CommonJS modules, with ES5 lang level. -2. **ESM**, the `/esm` folder — ES modules (browser compatible), with ES5 lang level. -3. **ESNext**, the `/esnext` folder — ES modules (browser compatible), with ESNext lang level. +2. **ESM**, the `/esm` folder — it is ES modules (browser compatible), with ES5 lang level. +3. **ESNext**, the `/esnext` folder — it is ES modules (browser compatible), with ESNext lang level. So, if you need the `useMountEffect` hook, depending on your needs, you can import it in three ways (there are actually more, but these are the three most common): diff --git a/package.json b/package.json index 1ace73ae8..b24142107 100644 --- a/package.json +++ b/package.json @@ -35,8 +35,8 @@ "commit": "git-cz", "build": "yarn build:cleanup && concurrently yarn:build:cjs yarn:build:esm yarn:build:esnext --kill-others-on-fail", "build:cleanup": "rimraf ./cjs ./esm ./esnext ./types", - "build:cjs": "ttsc -p ./tsconfig.build.json --module CommonJS --target ES5 --outDir ./cjs", - "build:esm": "ttsc -p ./tsconfig.build.json --module ES6 --target ES5 --outDir ./esm", + "build:cjs": "ttsc -p ./tsconfig.build.json --module CommonJS --target ES6 --outDir ./cjs", + "build:esm": "ttsc -p ./tsconfig.build.json --module ES6 --target ES6 --outDir ./esm", "build:esnext": "ttsc -p ./tsconfig.build.json --module ESNext --target ESNext --outDir ./esnext", "new-hook": "node ./utility/add-new-hook.js", "test": "jest --selectProjects dom ssr", diff --git a/src/__docs__/Introduction.story.mdx b/src/__docs__/Introduction.story.mdx index 43bc48ab3..6ada4ce79 100644 --- a/src/__docs__/Introduction.story.mdx +++ b/src/__docs__/Introduction.story.mdx @@ -44,8 +44,8 @@ transpile your `node-modules` in order to run in IE. This package provides three levels of compilation: 1. **Main**, the `/cjs` folder — CommonJS modules, with ES5 lang level. -2. **ESM**, the `/esm` folder — ES modules (browser compatible), with ES5 lang level. -3. **ESNext**, the `/esnext` folder — ES modules (browser compatible), with ESNext lang level. +2. **ESM**, the `/esm` folder — it is ES modules (browser compatible), with ES5 lang level. +3. **ESNext**, the `/esnext` folder — it is ES modules (browser compatible), with ESNext lang level. So, if you need the `useMountEffect` hook, depending on your needs, you can import it in three ways (there are actually more, but these are the three most common): diff --git a/tsconfig.build.json b/tsconfig.build.json index 8de296c40..7c8746f38 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -8,7 +8,7 @@ "noEmit": false, "outDir": "./cjs", "declaration": true, - "target": "ES5", + "target": "ES6", "module": "CommonJS", "moduleResolution": "Node", "sourceMap": false,