Skip to content

Commit

Permalink
Distribute completely separate files for the worker condition (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist authored Aug 22, 2023
1 parent eb4e4f1 commit b3dc597
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/gentle-carrots-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'react-textarea-autosize': patch
---

Distribute completely separate files for the `worker` condition to avoid bundlers from aliasing files targeting node to the ones targeting browsers through the `package.json#browser` alias field.
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
},
"development": {
"worker": {
"module": "./dist/react-textarea-autosize.development.esm.js",
"import": "./dist/react-textarea-autosize.development.cjs.mjs",
"default": "./dist/react-textarea-autosize.development.cjs.js"
"module": "./dist/react-textarea-autosize.development.worker.esm.js",
"import": "./dist/react-textarea-autosize.development.worker.cjs.mjs",
"default": "./dist/react-textarea-autosize.development.worker.cjs.js"
},
"browser": {
"module": "./dist/react-textarea-autosize.browser.development.esm.js",
Expand All @@ -41,9 +41,9 @@
"default": "./dist/react-textarea-autosize.development.cjs.js"
},
"worker": {
"module": "./dist/react-textarea-autosize.esm.js",
"import": "./dist/react-textarea-autosize.cjs.mjs",
"default": "./dist/react-textarea-autosize.cjs.js"
"module": "./dist/react-textarea-autosize.worker.esm.js",
"import": "./dist/react-textarea-autosize.worker.cjs.mjs",
"default": "./dist/react-textarea-autosize.worker.cjs.js"
},
"browser": {
"module": "./dist/react-textarea-autosize.browser.esm.js",
Expand All @@ -58,13 +58,13 @@
},
"imports": {
"#is-browser": {
"worker": "./src/resolved-conditions/false.ts",
"browser": "./src/resolved-conditions/true.ts",
"default": "./src/resolved-conditions/false.ts"
"worker": "./src/resolved-conditions/worker.ts",
"browser": "./src/resolved-conditions/browser.ts",
"default": "./src/resolved-conditions/node.ts"
},
"#is-development": {
"development": "./src/resolved-conditions/true.ts",
"default": "./src/resolved-conditions/false.ts"
"development": "./src/resolved-conditions/development.ts",
"default": "./src/resolved-conditions/production.ts"
}
},
"sideEffects": false,
Expand Down
2 changes: 1 addition & 1 deletion src/getSizingData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import isBrowser from '#is-browser';
import { isBrowser } from '#is-browser';
import { pick } from './utils';

const SIZING_STYLE = [
Expand Down
4 changes: 2 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import isDevelopment from '#is-development';
import isBrowser from '#is-browser';
import { isDevelopment } from '#is-development';
import { isBrowser } from '#is-browser';
import calculateNodeHeight from './calculateNodeHeight';
import getSizingData, { SizingData } from './getSizingData';
import {
Expand Down
1 change: 1 addition & 0 deletions src/resolved-conditions/browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const isBrowser = true;
1 change: 1 addition & 0 deletions src/resolved-conditions/development.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const isDevelopment = true;
1 change: 0 additions & 1 deletion src/resolved-conditions/false.ts

This file was deleted.

1 change: 1 addition & 0 deletions src/resolved-conditions/node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const isBrowser = false;
1 change: 1 addition & 0 deletions src/resolved-conditions/production.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const isDevelopment = false;
1 change: 0 additions & 1 deletion src/resolved-conditions/true.ts

This file was deleted.

1 change: 1 addition & 0 deletions src/resolved-conditions/worker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const isBrowser = false;

0 comments on commit b3dc597

Please sign in to comment.