-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat(tools): scripts and generator updates to enable SWC transpilation for v9 packages #26527
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
Merged
TristanWatanabe
merged 44 commits into
microsoft:master
from
TristanWatanabe:use-swc-transpilation-tooling-updates
Mar 17, 2023
Merged
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
ec31070
chore: add swc/cli as dev dep
TristanWatanabe 05be727
chore: add just-scripts-utils dev dep
TristanWatanabe e33940c
feat(migrate-converged-pkg): implement setup to add swcrc config file
TristanWatanabe 61a12fc
feat(scripts): add swc.ts file which runs SWC CLI
TristanWatanabe a15384f
feat(scripts): add just-script preset build:react-components to be us…
TristanWatanabe f93cc81
feat(migrate-converged-pkg): setup just config file to map just-scrip…
TristanWatanabe fa7434d
test(migrate-converged-pkg): add test cases for added behaviors
TristanWatanabe 316a71b
fix: deduplicate graceful-fs
TristanWatanabe ed944bd
fix: deduplicate just-scripts-utils and just-task-logger
TristanWatanabe f4146bc
fix: deduplicate semver
TristanWatanabe df9852e
fix(migrate-converged-pkg): add justConfig to projectConfig paths
TristanWatanabe 82f4a67
feat: simplify v9 compilation flow with swc
Hotell f85bc97
fixup! feat: simplify v9 compilation flow with swc
Hotell e8d5e73
fixup! fixup! feat: simplify v9 compilation flow with swc
Hotell 7d71a9a
Merge branch 'master' into use-swc-transpilation-tooling-updates
TristanWatanabe 40ab558
chore: update yarn.lock
TristanWatanabe 108daed
Merge remote-tracking branch 'hotell/swc-transpilation-simplification…
TristanWatanabe cdc90d6
nit: remove unintended prettier changes
TristanWatanabe 1afe76a
fix: use babel-plugin-module-resolver version 4.1.0 which works with …
TristanWatanabe 24989d6
chore: manually dedupe resolve package
TristanWatanabe 57303e5
test(migrate-converged-pkg): update babelrc setup test to be correct
TristanWatanabe 8b887a9
chore: add .swcrc to files v-build owns
TristanWatanabe 8656f48
chore: cleanup just preset.ts of unused code
TristanWatanabe 5473564
nit: remove unintended prettier change
TristanWatanabe 234cd93
nit: remove unintended prettier change
TristanWatanabe b43b595
nit: remove unintended prettier change
TristanWatanabe ad54b8a
chore: cleanup commented out code
TristanWatanabe 848e0c6
cleanup: remove unused just-scripts-utils dep
TristanWatanabe c40842f
Merge branch 'master' into use-swc-transpilation-tooling-updates
TristanWatanabe 77d4f9a
Merge branch 'master' into use-swc-transpilation-tooling-updates
TristanWatanabe 6572a66
chore: update yarn.lock after master merge
TristanWatanabe 3616186
feat: add monorepo root .babelrc-v9.json file and update migrate-conv…
TristanWatanabe 4dcbfc7
Merge branch 'master' into use-swc-transpilation-tooling-updates
TristanWatanabe 21b5a18
chore: update yarn.lock
TristanWatanabe bf390c0
fix(migrate-converged-generator): add react useBuiltIns config to swc…
TristanWatanabe 80f2432
test(migrate-converged): update test
TristanWatanabe 95f2686
chore: add bugfixes: true to swcrc file to suppress bundle size incre…
TristanWatanabe b8f6483
nit: remove ecma target from swcrc since it does nothing, browserlist…
TristanWatanabe 91bd611
Merge branch 'master' into use-swc-transpilation-tooling-updates
TristanWatanabe 6617e3f
nit: use optional chaining instead of bang operator for just config task
TristanWatanabe 90079dc
chore: add runtime:classic to swcrc
TristanWatanabe 6d3b05d
test: update test to reflect swcrc addition
TristanWatanabe 6913c18
Merge branch 'master' into use-swc-transpilation-tooling-updates
TristanWatanabe ca8f5dd
fix: replace useBuiltIns with useSpread to spread react props instead…
TristanWatanabe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "presets": [ | ||
| [ | ||
| "@griffel", | ||
| { | ||
| "babelOptions": { | ||
| "plugins": [ | ||
| [ | ||
| "babel-plugin-module-resolver", | ||
| { | ||
| "root": ["../../../"], | ||
| "alias": { | ||
| "@fluentui/tokens": "packages/tokens/lib/index.js", | ||
| "^@fluentui/(?!react-icons)(.+)": "packages/react-components/\\1/lib/index.js" | ||
| } | ||
| } | ||
| ] | ||
| ] | ||
| } | ||
| } | ||
| ] | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { exec } from 'child_process'; | ||
| import { promisify } from 'util'; | ||
|
|
||
| import { series } from 'just-scripts'; | ||
|
|
||
| import { apiExtractor } from './api-extractor'; | ||
|
|
||
| const execAsync = promisify(exec); | ||
|
|
||
| export function generateApi() { | ||
| return series(generateTypeDeclarations, apiExtractor); | ||
| } | ||
|
|
||
| function generateTypeDeclarations() { | ||
| const cmd = 'tsc -p ./tsconfig.lib.json --emitDeclarationOnly'; | ||
| return execAsync(cmd); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { exec } from 'child_process'; | ||
| import { promisify } from 'util'; | ||
|
|
||
| import type { Options as SwcOptions } from '@swc/core'; | ||
| import { logger } from 'just-scripts'; | ||
|
|
||
| const execAsync = promisify(exec); | ||
|
|
||
| type Options = SwcOptions & { module: { type: 'es6' | 'commonjs' | 'amd' } }; | ||
|
|
||
| function swcCli(options: Options) { | ||
| const { outputPath, module } = options; | ||
| const swcCliBin = 'npx swc'; | ||
| const sourceDirMap = { | ||
| es6: 'src', | ||
| commonjs: 'lib', | ||
| amd: 'lib', | ||
| }; | ||
| const sourceDir = sourceDirMap[options.module.type]; | ||
|
|
||
| const cmd = `${swcCliBin} ${sourceDir} --out-dir ${outputPath} --config module.type=${module?.type}`; | ||
| logger.info(`Running swc CLI: ${cmd}`); | ||
|
|
||
| return execAsync(cmd); | ||
| } | ||
|
|
||
| export const swc = { | ||
| commonjs: () => { | ||
| const options: Options = { | ||
| configFile: true, | ||
| outputPath: 'lib-commonjs', | ||
| module: { type: 'commonjs' }, | ||
| }; | ||
|
|
||
| return swcCli(options); | ||
| }, | ||
| esm: () => { | ||
| const options: Options = { | ||
| configFile: true, | ||
| outputPath: 'lib', | ||
| module: { type: 'es6' }, | ||
| }; | ||
|
|
||
| return swcCli(options); | ||
| }, | ||
| amd: () => { | ||
| const options: Options = { | ||
| configFile: true, | ||
| outputPath: 'lib-amd', | ||
| module: { type: 'amd' }, | ||
| }; | ||
|
|
||
| return swcCli(options); | ||
| }, | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.