Skip to content

Commit

Permalink
Publish both CJS and ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
samchon committed Mar 27, 2024
1 parent 58359a4 commit 3c2ce7c
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 23 deletions.
19 changes: 15 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
{
"name": "mutex-server",
"version": "0.4.0",
"version": "0.5.0",
"description": "Mutex Server using WebSocket",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"exports": {
".": {
"types": "./lib/index.d.ts",
"require": "./lib/index.js",
"import": "./lib/index.mjs"
}
},
"scripts": {
"build": "npm run build:main && npm run build:test",
"build:main": "rimraf lib && tsc",
"build:main": "rimraf lib && tsc && rollup -c",
"build:test": "rimraf bin && tsc --project test/tsconfig.json",
"dev": "npm run build:test -- --watch",
"prepare": "ts-patch install",
Expand Down Expand Up @@ -49,22 +56,26 @@
},
"homepage": "https://github.com/samchon/mutex",
"devDependencies": {
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/cli": "^0.11.19",
"@types/node": "^13.11.1",
"cli": "^1.0.1",
"prettier": "^3.2.5",
"rimraf": "^3.0.2",
"rollup": "^4.13.1",
"source-map-support": "^0.5.16",
"ts-node": "^8.8.2",
"ts-patch": "^3.1.2",
"tslib": "^2.6.2",
"typedoc": "^0.25.12",
"typescript": "^5.4.2",
"typescript-transform-paths": "^3.4.7"
},
"dependencies": {
"tgrid": "^0.9.0",
"tstl": "^2.5.13"
"tgrid": "^0.10.0",
"tstl": "^3.0.0"
},
"files": [
"LICENSE",
Expand Down
29 changes: 29 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const typescript = require("@rollup/plugin-typescript");
const terser = require("@rollup/plugin-terser");

module.exports = {
input: "./src/index.ts",
output: {
dir: "lib",
format: "esm",
entryFileNames: "[name].mjs",
sourcemap: true,
},
plugins: [
typescript({
tsconfig: "tsconfig.json",
module: "ES2020",
target: "ES2020",
}),
terser({
format: {
comments: "some",
beautify: true,
ecma: "2020",
},
compress: false,
mangle: false,
module: true,
}),
],
};
2 changes: 1 addition & 1 deletion src/server/ProviderGroup.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { WebAcceptor } from "tgrid";
import { List } from "tstl/container/List";
import { Joiner } from "./components/internal/Joiner";

import { GlobalGroup } from "./GlobalGroup";
Expand All @@ -8,6 +7,7 @@ import { SemaphoresProvider } from "./providers/SemaphoresProvider";
import { MutexesProvider } from "./providers/MutexesProvider";
import { BarriersProvider } from "./providers/BarriersProvider";
import { LatchesProvider } from "./providers/LatchesProvider";
import { List } from "tstl";

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion src/server/components/ServerConditionVariable.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { WebAcceptor } from "tgrid";
import { List, sleep_for } from "tstl";
import { LockType } from "tstl/lib/internal/thread/LockType";

import { SolidComponent } from "./SolidComponent";
import { LockType } from "tstl/internal/thread/LockType";
import { Joiner } from "./internal/Joiner";

/**
Expand Down
4 changes: 2 additions & 2 deletions src/server/components/ServerMutex.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { WebAcceptor } from "tgrid";
import { List, sleep_for, OutOfRange, Pair } from "tstl";
import { AccessType } from "tstl/internal/thread/AccessType";
import { LockType } from "tstl/internal/thread/LockType";
import { AccessType } from "tstl/lib/internal/thread/AccessType";
import { LockType } from "tstl/lib/internal/thread/LockType";

import { SolidComponent } from "./SolidComponent";
import { Disolver } from "./internal/Disolver";
Expand Down
2 changes: 1 addition & 1 deletion src/server/components/ServerSemaphore.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { WebAcceptor } from "tgrid";
import { List, sleep_for, OutOfRange, Pair } from "tstl";
import { LockType } from "tstl/internal/thread/LockType";
import { LockType } from "tstl/lib/internal/thread/LockType";

import { SolidComponent } from "./SolidComponent";
import { Disolver } from "./internal/Disolver";
Expand Down
2 changes: 1 addition & 1 deletion src/server/components/SolidComponent.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { WebAcceptor } from "tgrid";
import { HashMap, HashSet, List } from "tstl";
import { LockType } from "tstl/internal/thread/LockType";
import { LockType } from "tstl/lib/internal/thread/LockType";

import { IComponent } from "./IComponent";
import { Disolver } from "./internal/Disolver";
Expand Down
3 changes: 1 addition & 2 deletions src/server/providers/ProviderBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
*/
//-----------------------------------------------------------
import { WebAcceptor } from "tgrid";
import { List, HashSet } from "tstl";
import { List, HashSet, OutOfRange } from "tstl";

import { GlobalBase } from "../global/GlobalBase";
import { Joiner } from "../components/internal/Joiner";
import { OutOfRange } from "tstl/exception/OutOfRange";

/**
* @internal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { IPointer, sleep_for } from "tstl";
import { ConnectionFactory } from "../internal/ConnectionFactory";
import { sleep_for } from "tstl/thread/global";
import { IPointer } from "tstl/functional/IPointer";

async function wait_and_disconnect(
factory: ConnectionFactory,
Expand Down
2 changes: 1 addition & 1 deletion test/condition_variables/test_condition_variable_waits.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ConnectionFactory } from "../internal/ConnectionFactory";
import { sleep_for } from "tstl/thread/global";
import { sleep_for } from "tstl";

const SLEEP_TIME: number = 100;
const WAIT_COUNT: number = 10;
Expand Down
13 changes: 7 additions & 6 deletions test/internal/Validator.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { ILockable } from "tstl/base/thread/ILockable";
import { ITimedLockable } from "tstl/base/thread/ITimedLockable";
import { ISharedLockable } from "tstl/base/thread/ISharedLockable";
import { ISharedTimedLockable } from "tstl/base/thread/ISharedTimedLockable";

import { sleep_for } from "tstl/thread/global";
import { sleep_for } from "tstl";
import {
ILockable,
ITimedLockable,
ISharedLockable,
ISharedTimedLockable,
} from "tstl/lib/base/thread";

export namespace Validator {
const SLEEP_TIME = 50;
Expand Down
2 changes: 1 addition & 1 deletion test/semaphores/test_semaphore_acquires.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { MutexConnector, RemoteSemaphore } from "mutex-server";
import { sleep_for } from "tstl";
import { ITimedLockable } from "tstl/base/thread";

import { ConnectionFactory } from "../internal/ConnectionFactory";
import { IActivation } from "../internal/IActivation";
import { Validator } from "../internal/Validator";
import { ITimedLockable } from "tstl/lib/base/thread/ITimedLockable";

const SIZE = 8;

Expand Down
2 changes: 1 addition & 1 deletion test/test_destructors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sleep_for } from "tstl/thread/global";
import { sleep_for } from "tstl";
import { MutexConnector, MutexServer, RemoteMutex } from "mutex-server";
import { IActivation } from "./internal/IActivation";
import { ConnectionFactory } from "./internal/ConnectionFactory";
Expand Down

0 comments on commit 3c2ce7c

Please sign in to comment.