Skip to content

Commit

Permalink
fix(clerk-sdk-node): Revamp build for esm and cjs in preparation for v5
Browse files Browse the repository at this point in the history
  • Loading branch information
nikosdouvlis committed Dec 13, 2022
1 parent 63f5991 commit 3084825
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 42 deletions.
4 changes: 2 additions & 2 deletions packages/sdk-node/cjs/instance.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from '../dist/cjs/instance';
export { default } from '../dist/cjs/instance';
export * from '../dist/types/instance';
export { default } from '../dist/types/instance';
2 changes: 1 addition & 1 deletion packages/sdk-node/cjs/instance.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('../dist/cjs/instance');
module.exports = require('./../dist/instance');
4 changes: 2 additions & 2 deletions packages/sdk-node/esm/instance.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from '../dist/esm/instance';
export { default } from '../dist/esm/instance';
export * from '../dist/types/instance';
export { default } from '../dist/types/instance';
2 changes: 1 addition & 1 deletion packages/sdk-node/esm/instance.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('../dist/esm/instance');
export * from './../dist/instance.mjs';
29 changes: 22 additions & 7 deletions packages/sdk-node/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
{
"version": "4.5.11",
"license": "MIT",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"typings": "dist/cjs/index.d.ts",
"type": "commonjs",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/types/index.d.ts",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"default": "./dist/index.js"
},
"./esm/instance": {
"types": "./dist/types/instance.d.ts",
"default": "./dist/instance.mjs"
},
"./cjs/instance": {
"types": "./dist/types/instance.d.ts",
"default": "./dist/instance.js"
}
},
"files": [
"dist",
"package.json",
"esm",
"cjs"
],
"engines": {
"node": ">=14"
},
"scripts": {
"build:es5": "node ./scripts/info.js && tsc -p tsconfig.build.json",
"build:esm": "node ./scripts/info.js && tsc -p tsconfig.esm.json",
"build": "run-p build:es5 build:esm",
"dev": "tsup --watch",
"build": "tsup --env.NODE_ENV production",
"clean": "rimraf ./dist",
"lint": "eslint .",
"test": "jest",
Expand Down
9 changes: 0 additions & 9 deletions packages/sdk-node/tsconfig.build.json

This file was deleted.

9 changes: 0 additions & 9 deletions packages/sdk-node/tsconfig.esm.json

This file was deleted.

24 changes: 13 additions & 11 deletions packages/sdk-node/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
{
"include": ["src"],
"exclude": ["dist", "esm", "src/__tests__"],
"compilerOptions": {
"strict": true,
"declaration": true,
"declarationMap": false,
"downlevelIteration": true,
"sourceMap": false,
"declarationDir": "dist/types",
"declarationMap": true,
"emitDeclarationOnly": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"importHelpers": true,
"moduleResolution": "node",
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"forceConsistentCasingInFileNames": true,
"target": "ES2020",
"moduleResolution": "node",
"esModuleInterop": true
}
"resolveJsonModule": true,
"sourceMap": false,
"strict": true,
"target": "ES2020"
},
"exclude": ["node_modules"],
"include": ["src/index.ts", "src/instance.ts"]
}
24 changes: 24 additions & 0 deletions packages/sdk-node/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { defineConfig } from 'tsup';

import { name, version } from './package.json';

console.log({ name, version });
export default defineConfig(overrideOptions => {
const isProd = overrideOptions.env?.NODE_ENV === 'production';

return {
entry: ['src/index.ts', 'src/instance.ts'],
onSuccess: 'tsc',
clean: true,
// minify: isProd,
minify: false,
sourcemap: true,
format: ['cjs', 'esm'],
define: {
PACKAGE_NAME: `"${name}"`,
PACKAGE_VERSION: `"${version}"`,
__DEV__: `${!isProd}`,
},
external: [],
};
});

0 comments on commit 3084825

Please sign in to comment.