Skip to content

Commit

Permalink
fix(repo): build esm better
Browse files Browse the repository at this point in the history
  • Loading branch information
jrea committed Apr 9, 2024
1 parent a3885cc commit 86068ea
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 19 deletions.
13 changes: 9 additions & 4 deletions packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"license": "MIT",
"main": "./dist/index.js",
"module": "./dist/browser.esm.js",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/browser.esm.js"
}
},
"files": [
"dist"
],
Expand All @@ -12,9 +18,10 @@
},
"scripts": {
"start": "dts watch",
"build": "yarn build:move && yarn build:api:gen && dts build --tsconfig ./tsconfig.build.json",
"build": "yarn build:move && yarn build:api:gen && dts build --tsconfig ./tsconfig.build.json && yarn build:move-types",
"build:move": "node ./scripts/move.mjs",
"build:api:gen": "yarn openapi-generator-cli generate --skip-validate-spec -t templates -i src/spec.json -g typescript-fetch --package-name @niledatabase/client -o src/openapi --additional-properties=ngVersion=6.1.7,npmName=theniledev,supportsES6=true,npmVersion=6.9.0,withInterfaces=true,moduleName=NileClient,typescriptThreePlus=true,projectName=@niledatabase/browser",
"build:move-types": "cp dist/index.d.ts dist/browser.esm.d.ts",
"test": "dts test",
"lint": "eslint src",
"size": "size-limit",
Expand Down Expand Up @@ -50,11 +57,9 @@
"@size-limit/preset-small-lib": "^8.2.6",
"@types/jest": "^29.5.9",
"@types/node": "^18.18.11",
"dts-cli": "^2.0.3",
"size-limit": "^8.2.6",
"tslib": "^2.6.2",
"typescript": "^4.9.5"
},
"dependencies": {
"dts-cli": "^2.0.3"
}
}
8 changes: 1 addition & 7 deletions packages/react/dts.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const svgr = require('@svgr/rollup');
const babel = require('@rollup/plugin-babel');
const terser = require('rollup-plugin-terser');

module.exports = {
rollup(config) {
const basePlugins = config.plugins
.filter(Boolean)
.filter((config) => config.name !== 'babel')
.filter((config) => config.name !== 'terser');
config.plugins = [...basePlugins, babel(), svgr(), terser.terser()];
config.plugins.push(svgr());
return config;
},
};
10 changes: 8 additions & 2 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"license": "MIT",
"main": "./dist/index.js",
"module": "./dist/react.esm.js",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/react.esm.js"
}
},
"files": [
"dist"
],
Expand All @@ -12,7 +18,8 @@
},
"scripts": {
"start": "dts watch",
"build": "dts build --tsconfig tsconfig.build.json",
"build": "dts build --tsconfig tsconfig.build.json && yarn build:move-types",
"build:move-types": "cp dist/index.d.ts dist/react.esm.d.ts",
"test": "yarn jest",
"lint": "eslint src",
"size": "size-limit",
Expand Down Expand Up @@ -103,7 +110,6 @@
"@mui/x-data-grid": "^7.0.0",
"@niledatabase/browser": "^2.3.0-alpha.2",
"@tanstack/react-query": "^4.36.1",
"lodash": "^4.17.21",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.48.2",
Expand Down
3 changes: 1 addition & 2 deletions packages/react/src/hooks/useResults.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useMemo } from 'react';
import isObject from 'lodash/isObject';
import { GridColDef, GridRowsProp } from '@mui/x-data-grid';

import getColumnSize from '../utils/getColumnSize';
Expand Down Expand Up @@ -49,7 +48,7 @@ const parseResults = (
}
return Object.keys(row).reduce((accum: { [key: string]: string }, name) => {
accum[name] = row[name];
if (isObject(row[name])) {
if (row[name] && typeof row[name] === 'object') {
accum[name] = JSON.stringify(row[name]);
}
// useful for getRowId
Expand Down
4 changes: 1 addition & 3 deletions packages/react/src/utils/getColumnSize.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { GridRowsProp } from '@mui/x-data-grid';
import isNull from 'lodash/isNull';
import isUndefined from 'lodash/isUndefined';

export default function getColumnSize(
column: unknown,
Expand All @@ -13,7 +11,7 @@ export default function getColumnSize(
nextRow: { [key: string]: any }
) => {
let value = nextRow[String(column)];
if (isNull(value) || isUndefined(value)) {
if (value == null) {
value = '';
}
value = value?.toString();
Expand Down
1 change: 0 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3433,7 +3433,6 @@ __metadata:
husky: "npm:^8.0.3"
jest: "npm:^29.7.0"
jest-environment-jsdom: "npm:^29.7.0"
lodash: "npm:^4.17.21"
prop-types: "npm:^15.8.1"
react: "npm:^18.2.0"
react-dom: "npm:^18.2.0"
Expand Down

0 comments on commit 86068ea

Please sign in to comment.