-
Notifications
You must be signed in to change notification settings - Fork 8
chore: build project to emit cjs and esm using rollup #93
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,31 @@ | ||
{ | ||
"name": "decimal128", | ||
"version": "12.2.0", | ||
"main": "src/decimal128.js", | ||
"main": "dist/cjs/decimal128.cjs", | ||
"module": "dist/esm/decimal128.mjs", | ||
"typings": "dist/esm/decimal128.d.ts", | ||
"exports": { | ||
".": { | ||
"import": "./dist/esm/decimal128.mjs", | ||
"require": "./dist/cjs/decimal128.cjs", | ||
"types": "./dist/esm/decimal128.d.ts" | ||
} | ||
}, | ||
"type": "module", | ||
"description": "Partial implementation of IEEE 754 Decimal128 decimal floating-point numbers", | ||
"directories": { | ||
"test": "tests" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/jessealama/decimal128.js.git" | ||
}, | ||
"sideEffects": false, | ||
"scripts": { | ||
"build": "rollup -c", | ||
"test": "jest", | ||
"format": "prettier . --write", | ||
"lint": "prettier . --check", | ||
|
@@ -34,21 +47,21 @@ | |
"author": "Jesse Alama <[email protected]>", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@types/jest": "^29.5.1", | ||
"@rollup/plugin-typescript": "^11.1.6", | ||
"@types/jest": "^29.5.12", | ||
"c8": "^9.1.0", | ||
"jest": "^29.5.0", | ||
"jest": "^29.7.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was updating |
||
"jest-light-runner": "^0.6.0", | ||
"prettier": "^3.0.0", | ||
"ts-jest": "^29.1.0", | ||
"rollup": "^4.14.1", | ||
"ts-jest": "^29.1.2", | ||
"tslib": "^2.6.2", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see why we need tslib since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. likely a mistake, PR raised by Jesse in #121 no longer has this |
||
"typescript": "^5.1.3" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "BSD-2-Clause", | ||
"url": "https://opensource.org/license/bsd-2-clause/" | ||
} | ||
], | ||
"exports": { | ||
".": "./src/decimal128.mjs" | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// @ts-check | ||
import typescript from "@rollup/plugin-typescript"; | ||
|
||
/** | ||
* @param {'esm' | 'cjs'} format | ||
* @returns { import("rollup").RollupOptions } | ||
*/ | ||
const createConfig = (format) => { | ||
const extension = format === "esm" ? "mjs" : "cjs"; | ||
return { | ||
input: "src/decimal128.mts", | ||
output: [ | ||
{ | ||
sourcemap: true, | ||
interop: "esModule", | ||
preserveModules: true, | ||
dir: `./dist/${format}`, | ||
format: format, | ||
entryFileNames: `[name].${extension}`, | ||
}, | ||
], | ||
plugins: [ | ||
typescript({ | ||
tsconfig: "tsconfig.build.json", | ||
outDir: `dist/${format}`, | ||
sourceMap: false, | ||
}), | ||
], | ||
}; | ||
}; | ||
|
||
/** | ||
* @type { import("rollup").RollupOptions[] } | ||
*/ | ||
const config = [createConfig("esm"), createConfig("cjs")]; | ||
|
||
export default config; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"include": ["./src"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apologies, but I don't quite get this: which files were included so far? And why not just add the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In the original
Adding includes to the original tsconfig will prevent tsconfig from being applied to files outside of the My intention here with |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check out nodejs/node#52174, this pattern is not ideal and we should use the alternative mentioned in the thread.