Skip to content

Commit

Permalink
build: CRDT라이브러리 컴파일 다르게 설정
Browse files Browse the repository at this point in the history
- TypeScript는 CommonJs로 컴파일
- package.json exports 필드를 통해 ESM/CommonJS로 처리
- Jest는 ts-jest를 통해 TypeScript파일을 직접처리
  • Loading branch information
hyonun321 committed Nov 14, 2024
1 parent 7fd253c commit 03bd0a4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
23 changes: 14 additions & 9 deletions @noctaCrdt/package.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
{
"name": "@noctaCrdt",
"version": "1.0.0",
"main": "dist/Crdt.js",
"main": "./dist/Crdt.js",
"module": "./dist/Crdt.js",
"types": "dist/Crdt.d.ts",
"scripts": {
"build": "tsc -b"
},
"exports": {
"./Crdt": {
"types": "./dist/Crdt.d.ts",
"default": "./dist/Crdt.js"
"require": "./dist/Crdt.js",
"import": "./dist/Crdt.js",
"types": "./dist/Crdt.d.js"
},
"./Node": {
"types": "./dist/Node.d.ts",
"default": "./dist/Node.js"
"require": "./dist/Node.js",
"import": "./dist/Node.js",
"types": "./dist/Node.d.ts"
},
"./LinkedList": {
"types": "./dist/LinkedList.d.ts",
"default": "./dist/LinkedList.js"
"require": "./dist/LinkedList.js",
"import": "./dist/LinkedList.js",
"types": "./dist/LinkedList.d.ts"
},
"./Interfaces": {
"types": "./dist/Interfaces.d.ts",
"default": "./dist/Interfaces.js"
"require": "./dist/Interfaces.js",
"import": "./dist/Interfaces.js",
"types": "./dist/Interfaces.d.ts"
}
}
}
7 changes: 6 additions & 1 deletion @noctaCrdt/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"isolatedModules": true
"isolatedModules": true,
"module": "CommonJS",
"esModuleInterop": true,
"allowJs": true, // 추가
"moduleResolution": "node", // 추가
"target": "ES2021" // 추가
},
"include": ["**/*.ts"],
"exclude": ["node_modules", "dist"]
Expand Down
11 changes: 9 additions & 2 deletions server/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@ const config: Config = {
rootDir: ".",
testRegex: ".*\\.spec\\.ts$",
transform: {
"^.+\\.(t|j)s$": "ts-jest",
"^.+\\.(t|j)s$": [
"ts-jest",
{
tsconfig: "tsconfig.json",
},
],
},
collectCoverageFrom: ["**/*.(t|j)s"],
coverageDirectory: "./coverage",
testEnvironment: "node",
preset: "@shelf/jest-mongodb",
watchPathIgnorePatterns: ["globalConfig"],
moduleNameMapper: {
"^@noctaCrdt/(.*)$": "<rootDir>/../@noctaCrdt/dist/$1",
"^@noctaCrdt$": "<rootDir>/../@noctaCrdt/dist/Crdt.js",
"^@noctaCrdt/(.*)$": "<rootDir>/../@noctaCrdt/dist/$1.js",
},
transformIgnorePatterns: ["node_modules/(?!@noctaCrdt)"],
};

export default config;

0 comments on commit 03bd0a4

Please sign in to comment.