Skip to content

target=ES2020, dropping target=ES5 from dist #258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ benchmark/sandbox.ts
# v8 profiler logs
isolate-*.log

# tsimp
.tsimp/

# deno
deno.lock

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -632,11 +632,11 @@ Note that `JSON` cases use `Buffer` to emulate I/O where a JavaScript string mus

The NPM package distributed in npmjs.com includes both ES2015+ and ES5 files:

* `dist/` is compiled into ES2019 with CommomJS, provided for NodeJS v10
* `dist.es5+umd/` is compiled into ES5 with UMD
* `dist.es5+umd/msgpack.min.js` - the minified file
* `dist.es5+umd/msgpack.js` - the non-minified file
* `dist.es5+esm/` is compiled into ES5 with ES modules, provided for webpack-like bundlers and NodeJS's ESM-mode
* `dist/` is compiled into ES2020 with CommomJS, provided for NodeJS v10
* `dist.umd/` is compiled into ES5 with UMD
* `dist.umd/msgpack.min.js` - the minified file
* `dist.umd/msgpack.js` - the non-minified file
* `dist.esm/` is compiled into ES2020 with ES modules, provided for webpack-like bundlers and NodeJS's ESM-mode

If you use NodeJS and/or webpack, their module resolvers use the suitable one automatically.

Expand Down
2 changes: 1 addition & 1 deletion example/fetch-example.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<head>
<meta charset="UTF-8">
<script src="../dist.es5+umd/msgpack.min.js"></script>
<script src="../dist.umd/msgpack.min.js"></script>
<style>
main {
width: 80%;
Expand Down
6 changes: 3 additions & 3 deletions example/amd-example.html → example/umd-example.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="../dist.es5+umd/msgpack.min.js"></script>
<script src="../dist.umd/msgpack.min.js"></script>
<style>
main {
width: 80%;
Expand All @@ -11,9 +11,9 @@
</head>
<body>
<main>
<h1>AMD for @msgpack/msgpack</h1>
<h1>UMD for @msgpack/msgpack</h1>
<pre><code>&lt;script src="https://unpkg.com/@msgpack/msgpack"&gt;&lt;/script&gt;</code></pre>
<script src="./amd-example.js"></script>
<script src="./umd-example.js"></script>
</main>
</body>
</html>
File renamed without changes.
2 changes: 1 addition & 1 deletion mod.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./dist.es5+esm/index.mjs";
export * from "./dist.esm/index.mjs";
17 changes: 0 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"author": "The MessagePack community",
"license": "ISC",
"main": "./dist/index.js",
"module": "./dist.es5+esm/index.mjs",
"cdn": "./dist.es5+umd/msgpack.min.js",
"unpkg": "./dist.es5+umd/msgpack.min.js",
"module": "./dist.esm/index.mjs",
"cdn": "./dist.umd/msgpack.min.js",
"unpkg": "./dist.umd/msgpack.min.js",
"types": "./dist/index.d.ts",
"sideEffects": false,
"scripts": {
"build": "npm publish --dry-run",
"prepare": "npm run clean && webpack --bail && tsc --build tsconfig.dist.json tsconfig.dist.es5+esm.json && ts-node tools/esmify.ts dist.es5+esm/*.js dist.es5+esm/*/*.js",
"prepare": "npm run clean && webpack --bail && tsc --build tsconfig.dist.json tsconfig.dist.esm.json && ts-node tools/esmify.ts dist.esm/*.js dist.esm/*/*.js",
"prepublishOnly": "npm run test:dist",
"clean": "rimraf build dist dist.*",
"test": "mocha 'test/**/*.test.ts'",
Expand Down Expand Up @@ -50,7 +50,6 @@
"node": ">= 18"
},
"devDependencies": {
"@bitjourney/check-es-version-webpack-plugin": "latest",
"@eslint/compat": "latest",
"@eslint/eslintrc": "latest",
"@eslint/js": "latest",
Expand Down Expand Up @@ -90,7 +89,7 @@
"mod.ts",
"src/**/*.*",
"dist/**/*.*",
"dist.es5+umd/**/*.*",
"dist.es5+esm/**/*.*"
"dist.umd/**/*.*",
"dist.esm/**/*.*"
]
}
6 changes: 2 additions & 4 deletions tsconfig.dist.es5+esm.json → tsconfig.dist.esm.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "es5",
"module": "es2015",
"downlevelIteration": true,
"outDir": "./dist.es5+esm",
"module": "es2020",
"outDir": "./dist.esm",
"declaration": false,
"noEmitOnError": true,
"incremental": false
Expand Down
1 change: 0 additions & 1 deletion tsconfig.dist.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "es2019",
"outDir": "./dist",
"declaration": true,
"noEmitOnError": true,
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.dist.webpack.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "./tsconfig.es5.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "esnext",
"noEmitOnError": true,
Expand Down
8 changes: 0 additions & 8 deletions tsconfig.es5.json

This file was deleted.

2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
/* Basic Options */
"target": "ES2019", /* NodeJS v12 compatible */
"target": "ES2020", /* the baseline */
"module": "CommonJS", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"lib": ["ES2024", "dom"], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.test-karma.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "./tsconfig.es5.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "esnext",
"outDir": "./build/karma",
Expand Down
11 changes: 3 additions & 8 deletions webpack.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@ import path from "node:path";
import url from "node:url";
import webpack from "webpack";
import _ from "lodash";
// @ts-expect-error
import { CheckEsVersionPlugin } from "@bitjourney/check-es-version-webpack-plugin";

const dirname = path.dirname(url.fileURLToPath(import.meta.url));

const config = {
mode: "production",

entry: "./src/index.ts",
target: ["web", "es5"],
target: ["web", "es2020"],
output: {
path: path.resolve(dirname, "dist.es5+umd"),
path: path.resolve(dirname, "dist.umd"),
library: "MessagePack",
libraryTarget: "umd",
globalObject: "this",
Expand All @@ -35,9 +33,6 @@ const config = {
},

plugins: [
new CheckEsVersionPlugin({
esVersion: 5, // for IE11 support
}),
new webpack.DefinePlugin({
"process.env.TEXT_ENCODING": "undefined",
"process.env.TEXT_DECODER": "undefined",
Expand All @@ -55,7 +50,7 @@ const config = {
devtool: "source-map",
};

// eslint-disable-next-line import/no-default-export

export default [
((config) => {
config.output.filename = "msgpack.min.js";
Expand Down