Skip to content

Commit 955842d

Browse files
committed
target=2020
1 parent 45d105f commit 955842d

14 files changed

+27
-40
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ benchmark/sandbox.ts
99
# v8 profiler logs
1010
isolate-*.log
1111

12+
# tsimp
13+
.tsimp/
14+
1215
# deno
1316
deno.lock
1417

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -632,11 +632,11 @@ Note that `JSON` cases use `Buffer` to emulate I/O where a JavaScript string mus
632632

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

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

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

example/fetch-example.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<head>
55
<meta charset="UTF-8">
6-
<script src="../dist.es5+umd/msgpack.min.js"></script>
6+
<script src="../dist.umd/msgpack.min.js"></script>
77
<style>
88
main {
99
width: 80%;
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html lang="en">
33
<head>
4-
<script src="../dist.es5+umd/msgpack.min.js"></script>
4+
<script src="../dist.umd/msgpack.min.js"></script>
55
<style>
66
main {
77
width: 80%;
@@ -11,9 +11,9 @@
1111
</head>
1212
<body>
1313
<main>
14-
<h1>AMD for @msgpack/msgpack</h1>
14+
<h1>UMD for @msgpack/msgpack</h1>
1515
<pre><code>&lt;script src="https://unpkg.com/@msgpack/msgpack"&gt;&lt;/script&gt;</code></pre>
16-
<script src="./amd-example.js"></script>
16+
<script src="./umd-example.js"></script>
1717
</main>
1818
</body>
1919
</html>
File renamed without changes.

mod.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from "./dist.es5+esm/index.mjs";
1+
export * from "./dist.esm/index.mjs";

package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
"author": "The MessagePack community",
66
"license": "ISC",
77
"main": "./dist/index.js",
8-
"module": "./dist.es5+esm/index.mjs",
9-
"cdn": "./dist.es5+umd/msgpack.min.js",
10-
"unpkg": "./dist.es5+umd/msgpack.min.js",
8+
"module": "./dist.esm/index.mjs",
9+
"cdn": "./dist.umd/msgpack.min.js",
10+
"unpkg": "./dist.umd/msgpack.min.js",
1111
"types": "./dist/index.d.ts",
1212
"sideEffects": false,
1313
"scripts": {
1414
"build": "npm publish --dry-run",
15-
"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",
15+
"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",
1616
"prepublishOnly": "npm run test:dist",
1717
"clean": "rimraf build dist dist.*",
1818
"test": "mocha 'test/**/*.test.ts'",
@@ -90,7 +90,7 @@
9090
"mod.ts",
9191
"src/**/*.*",
9292
"dist/**/*.*",
93-
"dist.es5+umd/**/*.*",
94-
"dist.es5+esm/**/*.*"
93+
"dist.umd/**/*.*",
94+
"dist.esm/**/*.*"
9595
]
9696
}

tsconfig.dist.es5+esm.json renamed to tsconfig.dist.esm.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
{
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
4-
"target": "es5",
5-
"module": "es2015",
6-
"downlevelIteration": true,
7-
"outDir": "./dist.es5+esm",
4+
"module": "es2020",
5+
"outDir": "./dist.esm",
86
"declaration": false,
97
"noEmitOnError": true,
108
"incremental": false

tsconfig.dist.json

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
4-
"target": "es2019",
54
"outDir": "./dist",
65
"declaration": true,
76
"noEmitOnError": true,

tsconfig.dist.webpack.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "./tsconfig.es5.json",
2+
"extends": "./tsconfig.json",
33
"compilerOptions": {
44
"module": "esnext",
55
"noEmitOnError": true,

tsconfig.es5.json

-8
This file was deleted.

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"compilerOptions": {
33
/* Basic Options */
4-
"target": "ES2019", /* NodeJS v12 compatible */
4+
"target": "ES2020", /* the baseline */
55
"module": "CommonJS", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
66
"lib": ["ES2024", "dom"], /* Specify library files to be included in the compilation. */
77
// "allowJs": true, /* Allow javascript files to be compiled. */

tsconfig.test-karma.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "./tsconfig.es5.json",
2+
"extends": "./tsconfig.json",
33
"compilerOptions": {
44
"module": "esnext",
55
"outDir": "./build/karma",

webpack.config.mjs

+3-8
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@ import path from "node:path";
22
import url from "node:url";
33
import webpack from "webpack";
44
import _ from "lodash";
5-
// @ts-expect-error
6-
import { CheckEsVersionPlugin } from "@bitjourney/check-es-version-webpack-plugin";
75

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

108
const config = {
119
mode: "production",
1210

1311
entry: "./src/index.ts",
14-
target: ["web", "es5"],
12+
target: ["web", "es2020"],
1513
output: {
16-
path: path.resolve(dirname, "dist.es5+umd"),
14+
path: path.resolve(dirname, "dist.umd"),
1715
library: "MessagePack",
1816
libraryTarget: "umd",
1917
globalObject: "this",
@@ -35,9 +33,6 @@ const config = {
3533
},
3634

3735
plugins: [
38-
new CheckEsVersionPlugin({
39-
esVersion: 5, // for IE11 support
40-
}),
4136
new webpack.DefinePlugin({
4237
"process.env.TEXT_ENCODING": "undefined",
4338
"process.env.TEXT_DECODER": "undefined",
@@ -55,7 +50,7 @@ const config = {
5550
devtool: "source-map",
5651
};
5752

58-
// eslint-disable-next-line import/no-default-export
53+
5954
export default [
6055
((config) => {
6156
config.output.filename = "msgpack.min.js";

0 commit comments

Comments
 (0)