Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build tooling changes #2922

Merged
merged 12 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ const config: StorybookConfig = {
strictMode: true,
},
},
swc: () => ({
jsc: {
transform: {
react: {
// Do not require importing React into scope to use JSX
runtime: 'automatic',
},
},
},
}),
Comment on lines +20 to +29
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow:

  • pre-push hooks didn't like unused React imports in some stories (how did folks push to their branches before?)
  • Stories without React in scope won't compile


// we need to add aliases to webpack so it knows how to follow
// to the source of the packages rather than the built version (dist)
Expand Down
61 changes: 61 additions & 0 deletions .yarn/versions/60c2f256.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
releases:
"@radix-ui/number": minor
"@radix-ui/primitive": minor
"@radix-ui/react-accessible-icon": minor
"@radix-ui/react-accordion": minor
"@radix-ui/react-alert-dialog": minor
"@radix-ui/react-announce": minor
"@radix-ui/react-arrow": minor
"@radix-ui/react-aspect-ratio": minor
"@radix-ui/react-avatar": minor
"@radix-ui/react-checkbox": minor
"@radix-ui/react-collapsible": minor
"@radix-ui/react-collection": minor
"@radix-ui/react-compose-refs": minor
"@radix-ui/react-context": minor
"@radix-ui/react-context-menu": minor
"@radix-ui/react-dialog": minor
"@radix-ui/react-direction": minor
"@radix-ui/react-dismissable-layer": minor
"@radix-ui/react-dropdown-menu": minor
"@radix-ui/react-focus-guards": minor
"@radix-ui/react-focus-scope": minor
"@radix-ui/react-form": minor
"@radix-ui/react-hover-card": minor
"@radix-ui/react-id": minor
"@radix-ui/react-label": minor
"@radix-ui/react-menu": minor
"@radix-ui/react-menubar": minor
"@radix-ui/react-navigation-menu": minor
"@radix-ui/react-popover": minor
"@radix-ui/react-popper": minor
"@radix-ui/react-portal": minor
"@radix-ui/react-presence": minor
"@radix-ui/react-primitive": minor
"@radix-ui/react-progress": minor
"@radix-ui/react-radio-group": minor
"@radix-ui/react-roving-focus": minor
"@radix-ui/react-scroll-area": minor
"@radix-ui/react-select": minor
"@radix-ui/react-separator": minor
"@radix-ui/react-slider": minor
"@radix-ui/react-slot": minor
"@radix-ui/react-switch": minor
"@radix-ui/react-tabs": minor
"@radix-ui/react-toast": minor
"@radix-ui/react-toggle": minor
"@radix-ui/react-toggle-group": minor
"@radix-ui/react-toolbar": minor
"@radix-ui/react-tooltip": minor
"@radix-ui/react-use-callback-ref": minor
"@radix-ui/react-use-controllable-state": minor
"@radix-ui/react-use-escape-keydown": minor
"@radix-ui/react-use-layout-effect": minor
"@radix-ui/react-use-previous": minor
"@radix-ui/react-use-rect": minor
"@radix-ui/react-use-size": minor
"@radix-ui/react-visually-hidden": minor
"@radix-ui/rect": minor

declined:
- primitives
42 changes: 0 additions & 42 deletions babel.config.js

This file was deleted.

47 changes: 47 additions & 0 deletions build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { globSync } from 'glob';
import * as esbuild from 'esbuild';
import * as tsup from 'tsup';

async function build(path) {
const file = `${path}/src/index.ts`;
const dist = `${path}/dist`;

const esbuildConfig = {
entryPoints: [file],
external: ['@radix-ui/*'],
packages: 'external',
bundle: true,
sourcemap: true,
target: 'es2022',
outdir: dist,
};

await esbuild.build(esbuildConfig);
console.log(`Built ${path}/dist/index.js`);

await esbuild.build({
...esbuildConfig,
format: 'esm',
outExtension: { '.js': '.mjs' },
});
console.log(`Built ${path}/dist/index.mjs`);

// tsup is used to emit d.ts files only (esbuild can't do that).
//
// Notes:
// 1. Emitting d.ts files is super slow for whatever reason.
// 2. It could have fully replaced esbuild (as it uses that internally),
// but at the moment its esbuild version is somewhat outdated.
// It’s also harder to configure and esbuild docs are more thorough.
await tsup.build({
entry: [file],
format: ['cjs', 'esm'],
dts: { only: true },
outDir: dist,
silent: true,
external: [/@radix-ui\/.+/],
});
console.log(`Built ${path}/dist/index.d.ts`);
}
Comment on lines +29 to +45
Copy link
Collaborator Author

@vladmoroz vladmoroz May 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tsup gets the job done, but this is temporary—we'll probably just use tsc to compile the type definitions when stuff is updated to not need bundling in the first place:
#2922 (comment)


globSync('packages/*/*').forEach(build);
23 changes: 4 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,11 @@
"cypress:dev": "cypress open",
"dev": "yarn storybook",
"build-storybook": "storybook build",
"// build": "For context on tsconfig replacements in build scripts, see https://github.com/radix-ui/primitives/pull/361#discussion_r555004944",
"build": "yarn build:config && yarn build:packages && yarn build:cleanup",
"build:config": "mv tsconfig.json tsconfig.tmp.json && mv tsconfig.production.json tsconfig.json",
Comment on lines -21 to -23
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dance with configs isn't needed anymore

"build:packages": "parcel build 'packages/*/*/' --no-cache && yarn build:fix-type-defs",
"build:fix-type-defs": "node ./scripts/fix-type-defs-imports",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to fix the bugged imports anymore

"build:cleanup": "mv tsconfig.json tsconfig.production.json && mv tsconfig.tmp.json tsconfig.json",
"build": "node build.mjs",
"publish:stable": "yarn bump:stable && yarn clean && yarn build && yarn workspaces foreach -pvW --exclude primitives --exclude ssr-testing npm publish --tolerate-republish --access public",
"publish:next": "yarn bump:next && yarn clean && yarn build && yarn workspaces foreach -pvW --exclude primitives --exclude ssr-testing npm publish --tolerate-republish --access public --tag next",
"clean": "yarn workspaces foreach -pvW --exclude primitives --exclude ssr-testing run clean",
"reset": "yarn clean && rm -rf node_modules .yarn/cache .parcel-cache",
"reset": "yarn clean && rm -rf node_modules .yarn/cache",
"bump:stable": "yarn version apply --all",
"bump:next": "yarn version apply --all --prerelease",
"bump:check": "yarn version check"
Expand All @@ -37,14 +32,6 @@
"react-dom": "^18.0.0"
},
"devDependencies": {
"@babel/core": "^7.17.9",
"@babel/plugin-transform-typescript": "^7.16.8",
"@babel/preset-react": "^7.16.7",
"@babel/template": "^7.16.7",
"@parcel/babel-plugin-transform-runtime": "^2.4.1",
"@parcel/babel-preset-env": "^2.4.1",
"@parcel/packager-ts": "2.4.1",
"@parcel/transformer-typescript-types": "2.4.1",
"@stitches/core": "^1.2.8",
"@storybook/addon-essentials": "^7.6.17",
"@storybook/addon-storysource": "^7.6.17",
Expand All @@ -55,7 +42,6 @@
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.0.1",
"@testing-library/user-event": "^14.1.0",
"@types/babel__template": "^7.4.1",
"@types/eslint": "^7.28.0",
"@types/fs-extra": "^11",
"@types/jest": "^27.4.1",
Expand All @@ -65,10 +51,9 @@
"@types/react-test-renderer": "^18.0.0",
"@typescript-eslint/eslint-plugin": "^5.19.0",
"@typescript-eslint/parser": "^5.19.0",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.2.4",
"cypress": "^8.0.0",
"cypress-real-events": "^1.5.0",
"esbuild": "0.21.4",
"eslint": "^7.32.0",
"eslint-config-react-app": "^6.0.0",
"eslint-plugin-cypress": "^2.11.3",
Expand All @@ -85,14 +70,14 @@
"jest-axe": "^6.0.0",
"jest-watch-typeahead": "^1.0.0",
"lint-staged": "^10.5.3",
"parcel": "2.4.1",
"prettier": "^2.0.5",
"pretty-quick": "^2.0.1",
"react-test-renderer": "^18.0.0",
"replace-in-files": "^3.0.0",
"start-server-and-test": "^1.12.5",
"storybook": "^7.6.17",
"ts-jest": "^27.1.4",
"tsup": "8.0.2",
"typescript": "^4.6.3"
},
"resolutions": {
Expand Down
3 changes: 0 additions & 3 deletions packages/core/number/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,5 @@
},
"bugs": {
"url": "https://github.com/radix-ui/primitives/issues"
},
"dependencies": {
"@babel/runtime": "^7.13.10"
}
}
3 changes: 0 additions & 3 deletions packages/core/primitive/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,5 @@
},
"bugs": {
"url": "https://github.com/radix-ui/primitives/issues"
},
"dependencies": {
"@babel/runtime": "^7.13.10"
}
}
3 changes: 0 additions & 3 deletions packages/core/rect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,5 @@
},
"bugs": {
"url": "https://github.com/radix-ui/primitives/issues"
},
"dependencies": {
"@babel/runtime": "^7.13.10"
}
}
1 change: 0 additions & 1 deletion packages/react/accessible-icon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"version": "yarn version"
},
"dependencies": {
"@babel/runtime": "^7.13.10",
"@radix-ui/react-visually-hidden": "workspace:*"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { AccessibleIcon } from '@radix-ui/react-accessible-icon';

export default { title: 'Utilities/AccessibleIcon' };
Expand Down
1 change: 0 additions & 1 deletion packages/react/accordion/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"version": "yarn version"
},
"dependencies": {
"@babel/runtime": "^7.13.10",
"@radix-ui/primitive": "workspace:*",
"@radix-ui/react-collapsible": "workspace:*",
"@radix-ui/react-collection": "workspace:*",
Expand Down
1 change: 0 additions & 1 deletion packages/react/alert-dialog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"version": "yarn version"
},
"dependencies": {
"@babel/runtime": "^7.13.10",
"@radix-ui/primitive": "workspace:*",
"@radix-ui/react-compose-refs": "workspace:*",
"@radix-ui/react-context": "workspace:*",
Expand Down
1 change: 0 additions & 1 deletion packages/react/announce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"version": "yarn version"
},
"dependencies": {
"@babel/runtime": "^7.13.10",
"@radix-ui/react-compose-refs": "workspace:*",
"@radix-ui/react-primitive": "workspace:*",
"@radix-ui/react-use-layout-effect": "workspace:*"
Expand Down
1 change: 0 additions & 1 deletion packages/react/arrow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"version": "yarn version"
},
"dependencies": {
"@babel/runtime": "^7.13.10",
"@radix-ui/react-primitive": "workspace:*"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/react/arrow/src/Arrow.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { Arrow } from '@radix-ui/react-arrow';

export default { title: 'Utilities/Arrow' };
Expand Down
1 change: 0 additions & 1 deletion packages/react/arrow/src/Arrow.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { axe } from 'jest-axe';
import type { RenderResult } from '@testing-library/react';
import { render } from '@testing-library/react';
Expand Down
1 change: 0 additions & 1 deletion packages/react/aspect-ratio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"version": "yarn version"
},
"dependencies": {
"@babel/runtime": "^7.13.10",
"@radix-ui/react-primitive": "workspace:*"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/react/aspect-ratio/src/AspectRatio.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { css } from '../../../../stitches.config';
import { AspectRatio } from '@radix-ui/react-aspect-ratio';

Expand Down
1 change: 0 additions & 1 deletion packages/react/aspect-ratio/src/AspectRatio.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { axe } from 'jest-axe';
import type { RenderResult } from '@testing-library/react';
import { render } from '@testing-library/react';
Expand Down
1 change: 0 additions & 1 deletion packages/react/avatar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"version": "yarn version"
},
"dependencies": {
"@babel/runtime": "^7.13.10",
"@radix-ui/react-context": "workspace:*",
"@radix-ui/react-primitive": "workspace:*",
"@radix-ui/react-use-callback-ref": "workspace:*",
Expand Down
1 change: 0 additions & 1 deletion packages/react/avatar/src/Avatar.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { css } from '../../../../stitches.config';
import * as Avatar from '@radix-ui/react-avatar';

Expand Down
1 change: 0 additions & 1 deletion packages/react/avatar/src/Avatar.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { axe } from 'jest-axe';
import type { RenderResult } from '@testing-library/react';
import { render } from '@testing-library/react';
Expand Down
1 change: 0 additions & 1 deletion packages/react/checkbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"version": "yarn version"
},
"dependencies": {
"@babel/runtime": "^7.13.10",
"@radix-ui/primitive": "workspace:*",
"@radix-ui/react-compose-refs": "workspace:*",
"@radix-ui/react-context": "workspace:*",
Expand Down
1 change: 0 additions & 1 deletion packages/react/collapsible/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"version": "yarn version"
},
"dependencies": {
"@babel/runtime": "^7.13.10",
"@radix-ui/primitive": "workspace:*",
"@radix-ui/react-compose-refs": "workspace:*",
"@radix-ui/react-context": "workspace:*",
Expand Down
1 change: 0 additions & 1 deletion packages/react/collection/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"version": "yarn version"
},
"dependencies": {
"@babel/runtime": "^7.13.10",
"@radix-ui/react-compose-refs": "workspace:*",
"@radix-ui/react-context": "workspace:*",
"@radix-ui/react-primitive": "workspace:*",
Expand Down
3 changes: 0 additions & 3 deletions packages/react/compose-refs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,5 @@
},
"bugs": {
"url": "https://github.com/radix-ui/primitives/issues"
},
"dependencies": {
"@babel/runtime": "^7.13.10"
}
}
1 change: 0 additions & 1 deletion packages/react/context-menu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"version": "yarn version"
},
"dependencies": {
"@babel/runtime": "^7.13.10",
"@radix-ui/primitive": "workspace:*",
"@radix-ui/react-context": "workspace:*",
"@radix-ui/react-menu": "workspace:*",
Expand Down
Loading
Loading