From 3e0e3473122160b4e1f52fbc86b04d919f320b7a Mon Sep 17 00:00:00 2001 From: Jeongho Nam Date: Tue, 9 Jul 2024 10:34:14 +0900 Subject: [PATCH] Export ESM module at the same time --- package.json | 12 ++++++++---- rollup.config.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 rollup.config.js diff --git a/package.json b/package.json index 5b0e53d..bdde327 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,14 @@ { "name": "@samchon/openapi", - "version": "0.3.1", + "version": "0.3.2", "description": "OpenAPI definitions and converters for 'typia' and 'nestia'.", "main": "./lib/index.js", + "module": "./lib/index.mjs", "typings": "./lib/index.d.ts", "scripts": { "prepare": "ts-patch install", "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 -p test/tsconfig.json", "dev": "npm run build:test -- --watch", "test": "node bin/test" @@ -30,14 +31,17 @@ "homepage": "https://github.com/samchon/openapi", "devDependencies": { "@nestia/e2e": "^0.6.0", + "@rollup/plugin-terser": "^0.4.4", + "@rollup/plugin-typescript": "^11.1.6", "@trivago/prettier-plugin-sort-imports": "^4.3.0", "@types/node": "^20.12.7", "prettier": "^3.2.5", "rimraf": "^5.0.5", + "rollup": "^4.18.1", "ts-patch": "^3.2.1", - "typescript": "^5.5.2", + "typescript": "^5.5.3", "typescript-transform-paths": "^3.4.7", - "typia": "^6.3.1" + "typia": "^6.0.0" }, "files": [ "lib", diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..f948ecc --- /dev/null +++ b/rollup.config.js @@ -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, + }), + ], +};