Skip to content

Commit

Permalink
Merge pull request #787 from wheresrhys/rhys/ts-build-for-core
Browse files Browse the repository at this point in the history
build: use tsc to build core
  • Loading branch information
wheresrhys authored Aug 8, 2024
2 parents f114903 + f2f15f7 commit 6d6b7fb
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 54 deletions.
4 changes: 3 additions & 1 deletion jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
"skipLibCheck": true,
"noEmit": false,
"target": "es2021",
"allowImportingTsExtensions": true,
"removeComments": true
},
"include": [
"./packages/core/src/*.js"
"./packages/core/src/*.js",
"./packages/core/src/*.ts"
],
"exclude": [
"node_modules",
Expand Down
3 changes: 3 additions & 0 deletions packages/core/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tsconfig.*
scripts
src
8 changes: 4 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
"browser": "./dist/esm/index.js",
"import": {
"default": "./dist/esm/index.js",
"types": "./dist/esm/types/index.d.ts"
"types": "./dist/esm/index.d.ts"
},
"require": {
"types": "./dist/cjs/types/index.d.ts",
"types": "./dist/cjs/index.d.ts",
"default": "./dist/cjs/index.js"
}
},
"type": "module",
"types": "./dist/esm/types/index.d.ts",
"types": "./dist/esm/index.d.ts",
"scripts": {
"build": "rm -rf dist && rollup -c --environment FORMAT:cjs && rollup -c --environment FORMAT:esm"
"build": "rm -rf dist && tsc -p tsconfig.esm.json && tsc -p tsconfig.cjs.json && node ./scripts/declare-dist-type.js"
},
"repository": {
"type": "git",
Expand Down
49 changes: 0 additions & 49 deletions packages/core/rollup.config.js

This file was deleted.

15 changes: 15 additions & 0 deletions packages/core/scripts/declare-dist-type.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { writeFile } from 'fs/promises';
const longFormatNames = {
cjs: 'commonjs',
esm: 'module',
};

async function createPackageJson(format) {
const pkg = { type: longFormatNames[format] };

const location = `./dist/${format}`;
await writeFile(`${location}/package.json`, JSON.stringify(pkg, null, 2));
}

await createPackageJson('esm');
await createPackageJson('cjs');
49 changes: 49 additions & 0 deletions packages/core/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"compilerOptions": {
"inlineSourceMap": false,
"listEmittedFiles": false,
"listFiles": false,
"pretty": true,
"traceResolution": false,
"rootDir": "src",
"lib": [
"es2021",
"dom",
"dom.iterable"
],
"moduleResolution": "nodenext",
"allowJs": true,
"checkJs": true,
"strict": true,
"skipLibCheck": true,
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictFunctionTypes": true,
"downlevelIteration": true,
"forceConsistentCasingInFileNames": true,
"types": [],
"declaration": true,
"removeComments": true
},
"compileOnSave": false,
"exclude": ["node_modules", "src/__tests__"],
"include": ["src"]
}

















10 changes: 10 additions & 0 deletions packages/core/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"esModuleInterop": true,
"moduleResolution": "node",
"module": "commonjs",
"outDir": "dist/cjs",
"target": "es2021"
}
}
8 changes: 8 additions & 0 deletions packages/core/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"module": "nodenext",
"outDir": "dist/esm",
"target": "es2021"
}
}

0 comments on commit 6d6b7fb

Please sign in to comment.