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

replace tsc with swc for compiling TS source #2100

Merged
merged 13 commits into from
Jun 14, 2024
Merged

replace tsc with swc for compiling TS source #2100

merged 13 commits into from
Jun 14, 2024

Conversation

mayank99
Copy link
Contributor

@mayank99 mayank99 commented Jun 12, 2024

Changes

Previously, only tsc (TypeScript compiler) was being used to compile the .tsx/.ts source into .js and .d.ts files. This works, but is not very flexible and is super slow.

This PR changes the build process so that swc is used for generating the actual code (.js), and tsc is only used for generating types (.d.ts). This is faster, but more importantly, it allows much greater control over the build output.

In this PR, I've used swc to strip all code comments (something that tsc cannot do). In future PRs, I plan to make other changes to the output.

While verifying the build output, I also noticed that the prettier script (added in #1389) wasn't working, so I fixed it by changing the ignore-path.

Testing

Manually verified that the build output looks fine. CI is also passing, which means that dependent workspaces (react-workshop/e2e/a11y tests and all playgrounds) are happy with the output.

Further testing pending (at minimum I would like to test in webpack/CRA).

Docs

Added changesets, since this is a user-facing change.

@mayank99 mayank99 self-assigned this Jun 12, 2024
@mayank99 mayank99 mentioned this pull request Jun 12, 2024
@mayank99 mayank99 marked this pull request as ready for review June 12, 2024 19:40
@mayank99 mayank99 requested review from a team as code owners June 12, 2024 19:40
@mayank99 mayank99 requested review from r100-stack and Ben-Pusey-Bentley and removed request for a team June 12, 2024 19:40
Base automatically changed from mayank/bump-swc to main June 12, 2024 20:30
packages/itwinui-react/scripts/build.mjs Outdated Show resolved Hide resolved
packages/itwinui-react/package.json Show resolved Hide resolved
packages/itwinui-react/tsconfig.build.json Outdated Show resolved Hide resolved
.changeset/strange-spiders-count.md Show resolved Hide resolved
Copy link
Contributor

@Ben-Pusey-Bentley Ben-Pusey-Bentley left a comment

Choose a reason for hiding this comment

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

Looks good. Tested this out with a rudimentary create react app project, and it seems to work. screenshot:
image
App.js file:

import { Button, ThemeProvider } from '@itwin/itwinui-react';
import './App.css';

function App() {
  return (
    <ThemeProvider>
      <Button>Hello world</Button>
    </ThemeProvider>
  );
}

export default App;

@mayank99 mayank99 merged commit b0dc883 into main Jun 14, 2024
16 checks passed
@mayank99 mayank99 deleted the mayank/swc-build branch June 14, 2024 14:29
@imodeljs-admin imodeljs-admin mentioned this pull request Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants