Skip to content

apply pure ESM policy #259

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

Closed
wants to merge 4 commits into from
Closed
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
with:
deno-version: "v2.x"
- run: npm ci
- run: deno test test/deno_test.ts
- run: npm run test:deno

bun:
runs-on: ubuntu-latest
Expand All @@ -72,5 +72,5 @@ jobs:
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- run: bun install
- run: bun test test/bun.spec.ts
- run: npm run test:bun

9 changes: 4 additions & 5 deletions .mocharc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
'use strict';

require("ts-node/register");
"use strict";

module.exports = {
diff: true,
extension: ['ts'],
package: '../package.json',
extension: ["ts"],
package: "../package.json",
timeout: 10000,
require: ["tsimp"],
};
165 changes: 165 additions & 0 deletions package-lock.json

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

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@
"description": "MessagePack for ECMA-262/JavaScript/TypeScript",
"author": "The MessagePack community",
"license": "ISC",
"main": "./dist/index.js",
"main": "./dist.cjs/index.js",
"module": "./dist.esm/index.mjs",
"cdn": "./dist.umd/msgpack.min.js",
"unpkg": "./dist.umd/msgpack.min.js",
"types": "./dist/index.d.ts",
"types": "./dist.esm/index.d.ts",
"sideEffects": false,
"scripts": {
"build": "npm publish --dry-run",
"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",
"prepare": "npm run clean && webpack --bail && tsc --build tsconfig.dist.cjs.json tsconfig.dist.esm.json && tsimp tools/fix-ext.mts --mjs dist.esm/*.js dist.esm/*/*.js && tsimp tools/fix-ext.mts --cjs dist.cjs/*.js dist.cjs/*/*.js",
"prepublishOnly": "npm run test:dist",
"clean": "rimraf build dist dist.*",
"test": "mocha 'test/**/*.test.ts'",
"test:dist": "npm run lint && npm run test && npm run test:deno",
"test:cover": "npm run cover:clean && npx nyc --no-clean npm run 'test' && npm run cover:report",
"test:deno": "deno test test/deno_test.ts",
"test:bun": "bun test test/bun.spec.ts",
"test:fuzz": "npm exec --yes -- jsfuzz@git+https://gitlab.com/gitlab-org/security-products/analyzers/fuzzers/jsfuzz.git#39e6cf16613a0e30c7a7953f62e64292dbd5d3f3 --fuzzTime 60 --no-versifier test/decode.jsfuzz.js corpus",
"cover:clean": "rimraf .nyc_output coverage/",
"cover:report": "npx nyc report --reporter=text-summary --reporter=html --reporter=json",
Expand Down Expand Up @@ -81,6 +82,7 @@
"rimraf": "latest",
"ts-loader": "latest",
"ts-node": "latest",
"tsimp": "latest",
"typescript": "latest",
"webpack": "latest",
"webpack-cli": "latest"
Expand Down
2 changes: 1 addition & 1 deletion src/CachedKeyDecoder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { utf8DecodeJs } from "./utils/utf8";
import { utf8DecodeJs } from "./utils/utf8.ts";

const DEFAULT_MAX_KEY_LENGTH = 16;
const DEFAULT_MAX_LENGTH_PER_KEY = 16;
Expand Down
16 changes: 8 additions & 8 deletions src/Decoder.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { prettyByte } from "./utils/prettyByte";
import { ExtensionCodec, ExtensionCodecType } from "./ExtensionCodec";
import { getInt64, getUint64, UINT32_MAX } from "./utils/int";
import { utf8Decode } from "./utils/utf8";
import { ensureUint8Array } from "./utils/typedArrays";
import { CachedKeyDecoder, KeyDecoder } from "./CachedKeyDecoder";
import { DecodeError } from "./DecodeError";
import type { ContextOf } from "./context";
import { prettyByte } from "./utils/prettyByte.ts";
import { ExtensionCodec, ExtensionCodecType } from "./ExtensionCodec.ts";
import { getInt64, getUint64, UINT32_MAX } from "./utils/int.ts";
import { utf8Decode } from "./utils/utf8.ts";
import { ensureUint8Array } from "./utils/typedArrays.ts";
import { CachedKeyDecoder, KeyDecoder } from "./CachedKeyDecoder.ts";
import { DecodeError } from "./DecodeError.ts";
import type { ContextOf } from "./context.ts";

export type DecoderOptions<ContextType = undefined> = Readonly<
Partial<{
Expand Down
12 changes: 6 additions & 6 deletions src/Encoder.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { utf8Count, utf8Encode } from "./utils/utf8";
import { ExtensionCodec, ExtensionCodecType } from "./ExtensionCodec";
import { setInt64, setUint64 } from "./utils/int";
import { ensureUint8Array } from "./utils/typedArrays";
import type { ExtData } from "./ExtData";
import type { ContextOf } from "./context";
import { utf8Count, utf8Encode } from "./utils/utf8.ts";
import { ExtensionCodec, ExtensionCodecType } from "./ExtensionCodec.ts";
import { setInt64, setUint64 } from "./utils/int.ts";
import { ensureUint8Array } from "./utils/typedArrays.ts";
import type { ExtData } from "./ExtData.ts";
import type { ContextOf } from "./context.ts";

export const DEFAULT_MAX_DEPTH = 100;
export const DEFAULT_INITIAL_BUFFER_SIZE = 2048;
Expand Down
4 changes: 2 additions & 2 deletions src/ExtensionCodec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ExtensionCodec to handle MessagePack extensions

import { ExtData } from "./ExtData";
import { timestampExtension } from "./timestamp";
import { ExtData } from "./ExtData.ts";
import { timestampExtension } from "./timestamp.ts";

export type ExtensionDecoderType<ContextType> = (
data: Uint8Array,
Expand Down
6 changes: 3 additions & 3 deletions src/decode.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Decoder } from "./Decoder";
import type { DecoderOptions } from "./Decoder";
import type { SplitUndefined } from "./context";
import { Decoder } from "./Decoder.ts";
import type { DecoderOptions } from "./Decoder.ts";
import type { SplitUndefined } from "./context.ts";

/**
* It decodes a single MessagePack object in a buffer.
Expand Down
10 changes: 5 additions & 5 deletions src/decodeAsync.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Decoder } from "./Decoder";
import { ensureAsyncIterable } from "./utils/stream";
import type { DecoderOptions } from "./Decoder";
import type { ReadableStreamLike } from "./utils/stream";
import type { SplitUndefined } from "./context";
import { Decoder } from "./Decoder.ts";
import { ensureAsyncIterable } from "./utils/stream.ts";
import type { DecoderOptions } from "./Decoder.ts";
import type { ReadableStreamLike } from "./utils/stream.ts";
import type { SplitUndefined } from "./context.ts";

/**
* @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
Expand Down
6 changes: 3 additions & 3 deletions src/encode.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Encoder } from "./Encoder";
import type { EncoderOptions } from "./Encoder";
import type { SplitUndefined } from "./context";
import { Encoder } from "./Encoder.ts";
import type { EncoderOptions } from "./Encoder.ts";
import type { SplitUndefined } from "./context.ts";

/**
* It encodes `value` in the MessagePack format and
Expand Down
Loading
Loading