Skip to content

Commit

Permalink
fix(repository-tools): publish hybrid cjs/esm package
Browse files Browse the repository at this point in the history
Publish a cjs/esm version so that this package can be used more widely
  • Loading branch information
altano committed Aug 28, 2024
1 parent 786cbb2 commit e8ee7a9
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/spotty-snakes-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@altano/repository-tools": minor
---

publish hybrid cjs/esm package
12 changes: 12 additions & 0 deletions packages/build-config/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
extends: ["altano"],
overrides: [
{
files: ["**/*.ts", "**/*.tsx", "*.config.ts"],
parserOptions: {
project: ["./tsconfig.json"],
tsconfigRootDir: __dirname,
},
},
],
};
3 changes: 3 additions & 0 deletions packages/build-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
],
"publishConfig": {
"access": "restricted"
},
"devDependencies": {
"tsup": "^8.2.4"
}
}
9 changes: 9 additions & 0 deletions packages/build-config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"include": ["."],
"compilerOptions": {
"target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
"module": "NodeNext" /* Specify what module code is generated. */,
"strict": true /* Enable all strict type-checking options. */,
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}
25 changes: 25 additions & 0 deletions packages/build-config/tsup.config.node-hybrid.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { defineConfig } from "tsup";

export default defineConfig([
{
entry: ["./src/**/*.ts"],
format: "esm",
outDir: "dist/esm",
onSuccess: "pnpm build:types:esm",
clean: true,
platform: "node",
bundle: false,
minify: false,
},
{
entry: ["./src/**/*.ts"],
format: "cjs",
outDir: "dist/cjs",
legacyOutput: true,
onSuccess: "pnpm build:types:cjs",
clean: true,
platform: "node",
bundle: false,
minify: false,
},
]);
1 change: 0 additions & 1 deletion packages/build-config/tsup.config.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export default defineConfig({
onSuccess: "pnpm build:types",
dts: false,
clean: true,

platform: "node",
bundle: false,
minify: false,
Expand Down
13 changes: 9 additions & 4 deletions packages/repository-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@
"name": "@altano/repository-tools",
"version": "0.0.4",
"description": "Misc tools for dealing with repositories of multiple version control systems (git, svn, etc)",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"exports": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
},
"type": "module",
"sideEffects": false,
"files": [
"dist/**/*.js",
"dist/**/*.d.ts"
],
"scripts": {
"build": "tsup --config build-config/tsup.config.node.ts",
"build:types": "tsc --project tsconfig.declarations.json",
"build": "tsup --config build-config/tsup.config.node-hybrid.ts",
"build:types:cjs": "tsc --project tsconfig.declarations-cjs.json",
"build:types:esm": "tsc --project tsconfig.declarations-esm.json",
"clean": "rm -rf .turbo && rm -rf .tsbuildinfo && rm -rf node_modules && rm -rf dist",
"dev": "pnpm run build --watch",
"format": "prettier --check src",
Expand Down
13 changes: 13 additions & 0 deletions packages/repository-tools/tsconfig.declarations-cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "./tsconfig.json",
"include": ["src"],
"compilerOptions": {
"target": "ES2015",
"outDir": "./dist/cjs",
"moduleResolution": "Node10",
"module": "CommonJS",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "./tsconfig.json",
"include": ["src"],
"compilerOptions": {
"outDir": "./dist/esm",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true
Expand Down
6 changes: 5 additions & 1 deletion pnpm-lock.yaml

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

0 comments on commit e8ee7a9

Please sign in to comment.