-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Conversation
…thub.com/sourcegraph/sourcegraph into contractors/SG-45990
feat: add client packages to workspaces dependencies
Bundle size report 📦
Look at the Statoscope report for a full comparison between the commits a765b31 and b277484 or learn more. Open explanation
|
# We have to hoist eslint packages to use them in the `.eslintrc` config. | ||
public-hoist-pattern[]=*eslint* |
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.
This is only required when Storybook packages are hoisted. We can remove both patterns after upgrading Storybook to v7.
Codenotify: Notifying subscribers in CODENOTIFY files for diff b277484...a765b31.
|
Codenotify: Notifying subscribers in OWNERS files for diff b277484...a765b31.
|
pnpm
migration updatesyarn
to pnpm
Backend integration tests fail on |
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.
🚀 🚀 🚀
I wonder what's causing the bundle size to degree but I AM DOWN FOR IT!
Let's get this merged sooner rather than later, the surface for conflicts seem huge 😅
I was wondering if we can install a custom yarn
shim somehow that only does echo "Use pnpm instead" && exit 1
or so but I wouldn't know where to put it so that it is in everyone's PATH
and takes precedence over the asdf installation one 🤔
- uses: pnpm/action-setup@v2 | ||
id: pnpm-install | ||
with: | ||
version: 7.24.2 |
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.
To avoid hard coding the version in the github workflow, I've used this action before. Maybe we can reuse it here?
# The pnpm GitHub action does not support reading the version from
# .tool-versions yet so we have to be creative.
- name: Read .tool-versions
uses: marocchino/tool-versions-action@v1
id: versions
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ steps.versions.outputs.pnpm}}
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.
Nice find, I love that. Let's do it in a follow-up PR!
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 nice, that's awesome!
☝️ that's a great idea // the bundlesize thing concerns me a bit, there's no free drinks here, is it? 😆 |
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.
did a code pass, will do a functional test in a bit. LGTM! Thanks for working through this :)
"client/*", | ||
"dev/release" | ||
] | ||
}, | ||
"devDependencies": { |
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.
how come there are quite a few changes in the listed dependencies here?
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.
With node_modules hoisting disabled, pnpm makes it impossible to use packages not specified in the package.json file. This change revealed several dependencies we use but didn't add to our dependencies list explicitly.
@@ -1,6 +1,7 @@ | |||
lockfileVersion: 5.4 |
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.
were you able to keep exactly the same pinned versions that we had in yarn.lock? Just curious, not necessarily a blocker but would make this switch much less regression-prone.
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.
Yes, the pnpm import transforms the yarn.lock
file into the pnpm-lock.yaml
, preserving pinned versions.
@@ -233,6 +233,11 @@ const config = { | |||
resolve: { | |||
extensions: ['.mjs', '.ts', '.tsx', '.js', '.json'], | |||
mainFields: ['es2015', 'module', 'browser', 'main'], | |||
fallback: { |
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.
why was this not required before?
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.
It wasn't required before the package hoisting
was disabled. We can see that the main-dry-run build with hoisting=true
is green. My guess is that without hoisting some internal modules stopped having access to the hoisted implementations of these packages, that's why we now need to have fallbacks for them.
@@ -205,7 +196,7 @@ const webviewConfig = { | |||
loader: 'worker-loader', | |||
options: { inline: 'no-fallback' }, | |||
}, | |||
'ts-loader', | |||
getBabelLoader(), |
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.
what's the difference here?
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.
Hmm, interesting, the whole time we transpire vscode client with tsc instead of babel with TS preset?
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.
Yes, I tried to find the context behind this decision but didn't discover anything that prevents us from switching to babel. This was found when we bumped into TS errors upon building the VSCode extension, and it should not happen because we do type-checking as a separate CI step.
tried it locally, nothing broke :) |
@@ -1,18 +1,13 @@ | |||
import { Meta, Story } from '@storybook/react' | |||
import ParentSize from '@visx/responsive/lib/components/ParentSizeModern' | |||
|
|||
import webStyles from '@sourcegraph/web/src/SourcegraphWebApp.scss' | |||
import { BrandedStory } from '@sourcegraph/wildcard/src/stories' | |||
import { BrandedStory } from '../../../../stories' |
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.
I don't think the *.story.tsx
files are part of the @sourcegraph/wildcard
package? So should import by name like previously, instead of relatively within the package...
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.
We should update the configuration somehow to enable that. Typescript complains about absolute imports like that inside of the package because it cannot locate type definitions for @sourcegraph/wildcard/src/stories
. Let's discuss and update it in a follow-up PR.
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.
Tested manually, all standard flows work as expected (at least subset that I use), if CI is happy I'm happy too. Big thanks to @valerybugakov this is blazingly amazing
@@ -158,7 +158,7 @@ export const createSharedIntegrationTestContext = async < | |||
|
|||
// Fail the test in the case a request handler threw an error, | |||
// e.g. because a request had no mock defined. | |||
const cdpAdapter = polly.adapters.get(CdpAdapter.id) as CdpAdapter | |||
const cdpAdapter = polly.adapters.get(CdpAdapter.id) as unknown as CdpAdapter |
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.
Just out of curiosity is pnpm migration related to this and other TypeScript types fixes in this PR?
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.
This is a pnpm
migration-related change that started happening after disabling the package hoisting.
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.
It's related to the fact that I installed @types/pollyjs__adapter
to fix another TS issue before doing this change.
@@ -205,7 +196,7 @@ const webviewConfig = { | |||
loader: 'worker-loader', | |||
options: { inline: 'no-fallback' }, | |||
}, | |||
'ts-loader', | |||
getBabelLoader(), |
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.
Hmm, interesting, the whole time we transpire vscode client with tsc instead of babel with TS preset?
use: [ | ||
{ | ||
loader: 'ts-loader', | ||
}, | ||
], | ||
use: [getBabelLoader()], |
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 VSCode extensions changes were reviewed here:
Name: "yarn", | ||
Check: checkYarnVersion, | ||
Name: "pnpm", | ||
Check: checkPnpmVersion, |
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.
Tested locally by running: go run ./dev/sg setup -check
- uses: pnpm/action-setup@v2 | ||
id: pnpm-install | ||
with: | ||
version: 7.24.2 |
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.
Nice find, I love that. Let's do it in a follow-up PR!
@@ -158,7 +158,7 @@ export const createSharedIntegrationTestContext = async < | |||
|
|||
// Fail the test in the case a request handler threw an error, | |||
// e.g. because a request had no mock defined. | |||
const cdpAdapter = polly.adapters.get(CdpAdapter.id) as CdpAdapter | |||
const cdpAdapter = polly.adapters.get(CdpAdapter.id) as unknown as CdpAdapter |
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.
This is a pnpm
migration-related change that started happening after disabling the package hoisting.
@@ -158,7 +158,7 @@ export const createSharedIntegrationTestContext = async < | |||
|
|||
// Fail the test in the case a request handler threw an error, | |||
// e.g. because a request had no mock defined. | |||
const cdpAdapter = polly.adapters.get(CdpAdapter.id) as CdpAdapter | |||
const cdpAdapter = polly.adapters.get(CdpAdapter.id) as unknown as CdpAdapter |
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.
It's related to the fact that I installed @types/pollyjs__adapter
to fix another TS issue before doing this change.
@@ -233,6 +233,11 @@ const config = { | |||
resolve: { | |||
extensions: ['.mjs', '.ts', '.tsx', '.js', '.json'], | |||
mainFields: ['es2015', 'module', 'browser', 'main'], | |||
fallback: { |
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.
It wasn't required before the package hoisting
was disabled. We can see that the main-dry-run build with hoisting=true
is green. My guess is that without hoisting some internal modules stopped having access to the hoisted implementations of these packages, that's why we now need to have fallbacks for them.
@@ -1,18 +1,13 @@ | |||
import { Meta, Story } from '@storybook/react' | |||
import ParentSize from '@visx/responsive/lib/components/ParentSizeModern' | |||
|
|||
import webStyles from '@sourcegraph/web/src/SourcegraphWebApp.scss' | |||
import { BrandedStory } from '@sourcegraph/wildcard/src/stories' | |||
import { BrandedStory } from '../../../../stories' |
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.
We should update the configuration somehow to enable that. Typescript complains about absolute imports like that inside of the package because it cannot locate type definitions for @sourcegraph/wildcard/src/stories
. Let's discuss and update it in a follow-up PR.
Context
Bazel's rules_js rely on the
pnpm
package manager. To simplify the integration, we're migrating topnpm
from our current package manager —yarn
. Another reason to migrate is thatpnpm
is cool and fast. 😉Closes:
Breaking changes
If you used
yarn
commands directly, most of them should still work by replacingyarn
withpnpm
.E.g.,
yarn build-ts
—>pnpm build-ts
. For more advanced commands, refer to pnpm documentation.If you used only
sg
to interface with our npm scripts — nothing changes for you. Allsg
commands should work without changes.Test plan
Install
pnpm
locally withasdf install
ornpm i -g pnpm
.