Javascript/Typescipt support #17357
Replies: 14 comments 24 replies
-
What about test running, BTW? |
Beta Was this translation helpful? Give feedback.
-
I guess there are two different users (or projects) one may consider here. a) a novice (or new) project without any particular ties towards what's hip for the month. Just want it up and running smoothly, with as little bother as possible. b) an experienced user (or existing project) that want to leverage what Pants brings to the table. Would want to be able to re-use existing setup/configuration as much as possible. I've got a feeling that one may want to peel away as many layers as possible to avoid too much bloat floating around, which suggests that the setup supported for (b) ought to be a temporary position while migrating towards (a), while still using relevant tooling from the js ecosystem to get the job done. a balancing act for sure ;) I guess my question becomes, what technologies to support/accommodate, which to delegate to and how. Feels like it would be very easy to slip and drop down to becoming yet-another-js-build-tool. (well, which in a sense it is, but hopefully at a "higher level") perhaps closer to lerna in that sense. |
Beta Was this translation helpful? Give feedback.
-
I've done abit of hacking as a followup to my attempt to get the ball rolling in this area in #18138. I have a suggested design, which I'm under way with prototyping:
Example BUILD file for this suggestion: package_json(
package_manager="npm", # or yarn or pnmp, essentially package.json consumers, default configured in sub-system
scripts=[
node_build_script(entry_point="build", outputs=["dist"]), # A script specified in package.json that will tell pants it produces `resource()` targets
],
) The real kicker here I guess is A challenge here is how to facillitate caching to not make {
"name": "spam",
"private": true,
"version": "1.0.0",
"main": "./src/index.mjs",
"scripts": {
"build": "webpack"
},
"devDependencies": {"webpack": "4.0.1"}
} File-tree for the example:
I have working dependency inference using babel to parse I have the poc on a branch of my fork here with support for npm: https://github.com/tobni/pants/tree/add/node-package-goal. * seemed most prudent since |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
I'm actively working on this idea, current branch is https://github.com/tobni/pants/tree/add/node-build-scripts-resource-gen. I have working
|
Beta Was this translation helpful? Give feedback.
-
I have about 3.5k loc and working parcel integration tests now. I am unsure how to proceed in terms of contributing this to pants. But I think it would be benificial for me if this could be reviewed and mainlined/rejected, as the larger this change grows the more "in the wrong direction" I might be running. |
Beta Was this translation helpful? Give feedback.
-
Could someone please tag these with |
Beta Was this translation helpful? Give feedback.
-
Status update: Testing#18742 - Adds batch testing support to javascript tests. I did this because I think a lot of test-runner optimizations were dodged by pants "1 file 1 process" default behavior. Batching should remedy that. Package managers#18748 addresses #18525 and the issue of "how to support versions" for package managers. The PR does not introduce actual support for any other package managers Transpiled languages (mainly Typescript)There's no news here w.r.t to implementation. The current idea of implementing a plugin interface for I think the current javascript dependency inference needs to support the full import subpath syntax outlined in https://nodejs.org/docs/latest-v19.x/api/packages.html#subpath-imports. It is similar to typescripts https://www.typescriptlang.org/tsconfig#paths, which is why I mention it. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the update! Which of the PRs above are ready for review? |
Beta Was this translation helpful? Give feedback.
-
pnpm support: #18864 I think yarn support is a natural and cheap next step. |
Beta Was this translation helpful? Give feedback.
-
State of things:
@theoribeiro also did some exploratory testing (thank you!) which spawned:
I'm looking at starting to add a typescript backend, preparatory to that is:
|
Beta Was this translation helpful? Give feedback.
-
I'd like to air some details around the design space for a typescript backend, as I'd like to treat typescript both as a transpiled source, but also enable I think the path of least resistance for a check goal is This leads me to think maybe current The other thought is how to provide typescript sources to the Outstanding question is how to deal with .svelte, .vue, or w/e else is the next framework of the week. Maybe Typescript sources have special rules w.r.t to import strings that let them omit file endings and remap paths, this needs to be handled with separate logic in a typescript backend. Another thought that has occurred to me is the IDE support. I think Other than that, I believe a typescript backend is fairly straight forward. |
Beta Was this translation helpful? Give feedback.
-
I'd just like to say that I am still keen on continuing to implement JS support, even if my free time was ~gutted this summer. I'm hoping to be able to start tackling #19819 next month-ish, and then continue with the bigger issues like re-visiting how workspace packages are built to handle integrity files and inter-workspace references. |
Beta Was this translation helpful? Give feedback.
-
This PR introduces the building blocks to support any transpiled js dependency inference. I think it is the first missing piece for typescript, jsx, svelte and vue. My hope is to followup this PR with support for typescript, jsx and tsx support in build scripts and tests, as those are what my org uses. |
Beta Was this translation helpful? Give feedback.
-
High Level
prettier
is afmt
plugin, witheslint
support on the way as afix
and/orlint
plugin.This leaves us with the question(s) of transpiling/bundling and how they should work. The JS ecosystem is the wild west, with a new build system coming out ... monthly? So, the prospect of adding yet another tool to that mix doesn't give me the warm and fuzzies.
What would Pants's "purpose" be in TS/JS support? Would the idea be to be:
A) a replacement for stuff like
webpack
,vite
,esbuild
(yay Go),swc
(yay Rust),turbopack
(yay Rust again?), etc (to which I'm a giant 👎 ) - or,B) would it be to use those as plugins and facilitate their usage in a consistent matter, and maybe throw some dep inference + caching in for good measure, or
C) Alternative/middleground
The prospect of using Pants and migrating config from
vite
to yet another transpiler/builder (since the JS ecosystem is the wild west), is a non-starter for me.Notable Notes and Quotable Quotes from the Slack thread
Beta Was this translation helpful? Give feedback.
All reactions