-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Use babel to transpile TS projects #47502
Changes from all commits
754d9f0
b1437cb
f30a2ee
4e6d7ce
f3a6ae0
2bb6c25
4d29dab
b64457b
b35c0c5
6278a0d
fcf7ac7
1712884
df001a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,9 @@ | |
"homepage": "https://github.com/Automattic/wp-calypso", | ||
"license": "GPL-2.0-or-later", | ||
"author": "Automattic Inc.", | ||
"main": "dist/cjs/index", | ||
"module": "dist/esm/index", | ||
"main": "dist/cjs/index.js", | ||
"module": "dist/esm/index.js", | ||
"calypso:src": "src/index.ts", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Automattic/wp-calypso.git", | ||
|
@@ -17,9 +18,9 @@ | |
"url": "https://github.com/Automattic/wp-calypso/issues" | ||
}, | ||
"scripts": { | ||
"clean": "tsc --build ./tsconfig.json --clean && tsc --build ./tsconfig-cjs.json --clean", | ||
"prepublish": "yarn run clean", | ||
"prepare": "tsc --build ./tsconfig.json && tsc --build ./tsconfig-cjs.json", | ||
"clean": "tsc --build ./tsconfig.json ./tsconfig-cjs.json --clean && npx rimraf dist", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
"build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json", | ||
sirreal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"prepack": "yarn run clean && yarn run build", | ||
"watch": "tsc --build ./tsconfig.json --watch" | ||
}, | ||
"dependencies": { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": "./tsconfig", | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"declaration": false, | ||
"declarationMap": false, | ||
"declarationDir": null, | ||
"outDir": "dist/cjs", | ||
"composite": false, | ||
"incremental": true | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
"jsx": "react", | ||
"declaration": true, | ||
"declarationDir": "dist/types", | ||
"outDir": "dist/types", | ||
"outDir": "dist/esm", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I pushed a fix, esm build was being written to the wrong place 🙂 |
||
"isolatedModules": true, | ||
|
||
"strict": true, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
export { default, Props } from './domain-picker'; | ||
export { default } from './domain-picker'; | ||
export type { Props } from './domain-picker'; | ||
|
||
export { ITEM_TYPE_RADIO, ITEM_TYPE_BUTTON } from './domain-picker/suggestion-item'; | ||
export type { SUGGESTION_ITEM_TYPE } from './domain-picker/suggestion-item'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also a
packages/languages
package that is written in TypeScript and isn't being migrated in this PR: it's still built during theprepare
step.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/languages
is migrated in the sense that hascalypso:src
, but still requires a build step because we do use it to build Calypso:yarn build-languages
callsbin/build-languages.js
which requires'@automattic/languages'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see, the package is used by a Node.js build script and needs to be built 🙁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
@automattic/languages
is in a very similar situation as a Gutenberg webpack plugin we're discussing with @sirreal in WordPress/gutenberg#26382 (comment)I think we'd be better off if the package was written in plain JavaScript, where it would be a trivial two-liner:
and if the types were in a separate
index.d.ts
file.Then the package wouldn't need any build step at all, could be directly consumed by Node.js build scripts, and consumers would still get TypeScript types for it without any observable change.
This approach is an exception rather that a rule, but I think it would be justified for certain packages like these I mention.