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

Clean up build scripts #12305

Merged
merged 26 commits into from
Jan 31, 2025
Merged

Clean up build scripts #12305

merged 26 commits into from
Jan 31, 2025

Conversation

phryneas
Copy link
Member

The goal of this PR is to move the build scripts to TS,
use node with --experimental-strip-types instead of ts-node
and unify all the helpers we have in "scripts" - we are in a jungle
of "node run calls more node run".

That should give us a starting point to grok what our current build
actually does and which parts of it we need to modernize.

Copy link

changeset-bot bot commented Jan 24, 2025

⚠️ No Changeset found

Latest commit: 2b77df6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@svc-apollo-docs
Copy link

svc-apollo-docs commented Jan 24, 2025

⚠️ Docs preview not attached to branch

The preview was not built because the PR's base branch release-4.0 is not in the list of sources.

An Apollo team member can comment one of the following commands to dictate which branch to attach the preview to:

  • !docs set-base-branch version-2.6
  • !docs set-base-branch main

Build ID: 8bc0a4ada48596c908f45249

Copy link

netlify bot commented Jan 24, 2025

Deploy Preview for apollo-client-docs ready!

Name Link
🔨 Latest commit 2b77df6
🔍 Latest deploy log https://app.netlify.com/sites/apollo-client-docs/deploys/679c901f4c52a30008474344
😎 Deploy Preview https://deploy-preview-12305--apollo-client-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

pkg-pr-new bot commented Jan 24, 2025

npm i https://pkg.pr.new/@apollo/client@12305

commit: 2b77df6

Copy link
Contributor

github-actions bot commented Jan 24, 2025

size-limit report 📦

Path Size
dist/apollo-client.min.cjs 33.47 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" 41.41 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" (production) 38.72 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/index.js" 36.15 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/index.js" (production) 33.55 KB (0%)
import { ApolloProvider } from "dist/react/index.js" 1.26 KB (0%)
import { ApolloProvider } from "dist/react/index.js" (production) 1.24 KB (0%)
import { useQuery } from "dist/react/index.js" 5.12 KB (0%)
import { useQuery } from "dist/react/index.js" (production) 4.21 KB (0%)
import { useLazyQuery } from "dist/react/index.js" 5.61 KB (0%)
import { useLazyQuery } from "dist/react/index.js" (production) 4.68 KB (0%)
import { useMutation } from "dist/react/index.js" 3.62 KB (0%)
import { useMutation } from "dist/react/index.js" (production) 2.84 KB (0%)
import { useSubscription } from "dist/react/index.js" 4.43 KB (0%)
import { useSubscription } from "dist/react/index.js" (production) 3.48 KB (0%)
import { useSuspenseQuery } from "dist/react/index.js" 5.51 KB (0%)
import { useSuspenseQuery } from "dist/react/index.js" (production) 4.17 KB (0%)
import { useBackgroundQuery } from "dist/react/index.js" 5.01 KB (0%)
import { useBackgroundQuery } from "dist/react/index.js" (production) 3.66 KB (0%)
import { useLoadableQuery } from "dist/react/index.js" 5.09 KB (0%)
import { useLoadableQuery } from "dist/react/index.js" (production) 3.74 KB (0%)
import { useReadQuery } from "dist/react/index.js" 3.41 KB (0%)
import { useReadQuery } from "dist/react/index.js" (production) 3.35 KB (0%)
import { useFragment } from "dist/react/index.js" 2.01 KB (0%)
import { useFragment } from "dist/react/index.js" (production) 1.95 KB (0%)

Comment on lines -71 to -73
"engines": {
"npm": "^7.20.3 || ^8.0.0 || ^9.0.0 || ^10.0.0"
Copy link
Member Author

@phryneas phryneas Jan 24, 2025

Choose a reason for hiding this comment

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

The engines field was kinda weird as we can tell our consumers which runtime Apollo Client works in, but it doesn't make any sense to prescribe which package manager it works in.

We can also never drop anything from that list without a major. Removing it. We might add a node field here to indicate actual runtime compatibility, but that's not a concern for this PR and I'm not sure if we should.

"changeset-publish": "npm run build && npm run prepdist:changesets && cd dist && changeset publish",
"changeset-check": "changeset status --verbose --since=origin/main",
"pkg-pr-new-publish": "npm run build && cd dist && pkg-pr-new publish --no-template --compact",
"changeset-version": "changeset version && npm i",
"update-size-limits": "size-limit --json | jq '. | map(select(.sizeLimit) | { key: .name, value: .size}) | from_entries' | tee .new-size-limits.json; mv .new-size-limits.json .size-limits.json"
},
"engines": {
"npm": "^7.20.3 || ^8.0.0 || ^9.0.0 || ^10.0.0"
"devEngines": {
Copy link
Member Author

Choose a reason for hiding this comment

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

Instead I'm adding a devEngines field which allows us to specify which tooling should be used to develop Apollo Client - we don't need to be backwards compatible here but can bump it from time to time.

Starting with node 22.6 and the npm version that was released alongside with it here, as that's the node version that introduced --experimental-strip-types.

We could also go for 23.6 to unflag it (here and everywhere else) - I'm open for discussion :)

Copy link
Member

Choose a reason for hiding this comment

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

I'm down for 23.6. I just ran the build script with that version installed with no issues, so might as well go for it.

Comment on lines -37 to -44
"update-version": "node config/version.js update",
"verify-version": "node config/version.js verify",
"invariants": "ts-node-script config/processInvariants.ts",
"sourcemaps": "ts-node-script config/rewriteSourceMaps.ts",
"rollup": "rollup -c ./config/rollup.config.js",
"prepdist": "node ./config/prepareDist.js",
"prepdist:changesets": "ts-node-script config/prepareChangesetsRelease.ts",
"postprocess-dist": "ts-node-script config/postprocessDist.ts",
Copy link
Member Author

Choose a reason for hiding this comment

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

Most of these were called by postbuild, but we never called them manually on the CLI, so I removed them here.

prepdist:changesets and inline-inherit-doc were inlined further down in the commands that call them.

const allSteps = Object.assign({}, buildSteps, additionalSteps);

const runSteps = args.values.step.flatMap((step) =>
step === "build" ? Object.keys(buildSteps) : [step]
Copy link
Member Author

Choose a reason for hiding this comment

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

Calling this with --step=build is a shorthand for the normal build steps - that makes it possible to call it with --step=build --step=prepareChangesetsRelease instead of being forced to use a much longer command.

Comment on lines +9 to +10
- if (isTS) {
+ if (isTS && !process.features.typescript) {
Copy link
Member Author

Choose a reason for hiding this comment

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

@phryneas phryneas marked this pull request as ready for review January 28, 2025 12:41
@phryneas phryneas requested a review from jerelmiller January 28, 2025 12:42
Copy link
Member

@jerelmiller jerelmiller left a comment

Choose a reason for hiding this comment

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

Good stuff! Thanks for modernizing these

@phryneas phryneas merged commit 6585f99 into release-4.0 Jan 31, 2025
48 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants