Skip to content

Commit

Permalink
Fix CRA v5 compatibility by publishing lib and app as CommonJS packages
Browse files Browse the repository at this point in the history
  • Loading branch information
axelboc committed Mar 9, 2022
1 parent aaa8c99 commit 9375f9b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
9 changes: 5 additions & 4 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
],
"main": "src/index.ts",
"publishConfig": {
"main": "dist/index.cjs",
"module": "dist/index.js",
"type": "commonjs",
"main": "dist/index.js",
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
"exports": {
"./dist/styles.css": "./dist/styles.css",
"./styles.css": "./dist/styles.css",
".": {
"require": "./dist/index.cjs",
"import": "./dist/index.js"
"require": "./dist/index.js",
"import": "./dist/index.esm.js"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/app/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default defineConfig({
lib: {
entry: path.resolve('src/index.ts'),
formats: ['es', 'cjs'],
fileName: (format) => `index.${format === 'es' ? 'js' : 'cjs'}`,
fileName: (format) => `index.${format === 'es' ? 'esm.js' : 'js'}`,
},
rollupOptions: {
external: [...externals].map((dep) => new RegExp(`^${dep}($|\\/)`, 'u')), // e.g. externalize `react-icons/fi`
Expand Down
9 changes: 5 additions & 4 deletions packages/lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
],
"main": "src/index.ts",
"publishConfig": {
"main": "dist/index.cjs",
"module": "dist/index.js",
"type": "commonjs",
"main": "dist/index.js",
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
"exports": {
"./dist/styles.css": "./dist/styles.css",
"./styles.css": "./dist/styles.css",
".": {
"require": "./dist/index.cjs",
"import": "./dist/index.js"
"require": "./dist/index.js",
"import": "./dist/index.esm.js"
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions packages/lib/src/vis/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import type { Camera } from '@react-three/fiber';
import { scaleLinear, scaleThreshold } from '@visx/scale';
import { tickStep, range } from 'd3-array';
import type { ScaleLinear, ScaleThreshold } from 'd3-scale';
import { clamp } from 'lodash';
import type { IUniform } from 'three';
import { Vector3, Matrix4, Vector2 } from 'three';
import { clamp } from 'three/src/math/MathUtils';
import { Vector3, Matrix4 } from 'three';

import type {
Size,
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default defineConfig({
lib: {
entry: path.resolve('src/index.ts'),
formats: ['es', 'cjs'],
fileName: (format) => `index.${format === 'es' ? 'js' : 'cjs'}`,
fileName: (format) => `index.${format === 'es' ? 'esm.js' : 'js'}`,
},
rollupOptions: {
external: [...externals].map((dep) => new RegExp(`^${dep}($|\\/)`, 'u')), // e.g. externalize `react-icons/fi`
Expand Down

0 comments on commit 9375f9b

Please sign in to comment.