Skip to content

refactor: use pnpm to run the build-web script #1

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
merged 2 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
541 changes: 0 additions & 541 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

This file was deleted.

28 changes: 0 additions & 28 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

This file was deleted.

783 changes: 0 additions & 783 deletions .yarn/releases/yarn-3.2.3.cjs

This file was deleted.

29 changes: 0 additions & 29 deletions .yarnrc.yml

This file was deleted.

27 changes: 21 additions & 6 deletions client/build-config/src/paths.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
import { realpathSync } from 'fs'
import path from 'path'

export const ROOT_PATH = path.resolve(__dirname, '../../../')
export const WORKSPACES_PATH = path.resolve(ROOT_PATH, 'client')
export const NODE_MODULES_PATH = path.resolve(ROOT_PATH, 'node_modules')
export const MONACO_EDITOR_PATH = path.resolve(NODE_MODULES_PATH, 'monaco-editor')
export const STATIC_ASSETS_PATH = path.resolve(ROOT_PATH, 'ui/assets')
export const STATIC_INDEX_PATH = path.resolve(STATIC_ASSETS_PATH, 'index.html')
// NOTE: use fs.realpathSync() in addition to path.resolve() to resolve
// symlinks to the real path. This is required for webpack plugins using
// `include: [...file path...]` when the file path contains symlinks such
// as when using pnpm.
function resolve(...args: string[]): string {
const resolvedPath = path.resolve(...args)

try {
return realpathSync(resolvedPath)
} catch {
return resolvedPath
}
}

export const ROOT_PATH = resolve(__dirname, '../../../')
export const WORKSPACES_PATH = resolve(ROOT_PATH, 'client')
export const NODE_MODULES_PATH = resolve(ROOT_PATH, 'node_modules')
export const MONACO_EDITOR_PATH = resolve(NODE_MODULES_PATH, 'monaco-editor')
export const STATIC_ASSETS_PATH = resolve(ROOT_PATH, 'ui/assets')
export const STATIC_INDEX_PATH = resolve(STATIC_ASSETS_PATH, 'index.html')
2 changes: 1 addition & 1 deletion client/shared/dev/generateCssModulesTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const path = require('path')
const REPO_ROOT = path.join(__dirname, '../../..')
const CSS_MODULES_GLOB = path.resolve(__dirname, '../../*/src/**/*.module.scss')
const JETBRAINS_CSS_MODULES_GLOB = path.resolve(__dirname, '../../jetbrains/webview/**/*.module.scss')
const TSM_COMMAND = `yarn tsm --logLevel error "{${CSS_MODULES_GLOB},${JETBRAINS_CSS_MODULES_GLOB}}" --includePaths node_modules client`
const TSM_COMMAND = `pnpm tsm --logLevel error "{${CSS_MODULES_GLOB},${JETBRAINS_CSS_MODULES_GLOB}}" --includePaths node_modules client`
const [BIN, ...ARGS] = TSM_COMMAND.split(' ')

/**
Expand Down
4 changes: 2 additions & 2 deletions client/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
"storybook": "STORIES_GLOB='client/web/src/**/*.story.tsx' yarn workspace @sourcegraph/storybook run start",
"serve:dev": "yarn run -T ts-node-transpile-only --project ./dev/tsconfig.json ./dev/server/development.server.ts",
"serve:prod": "yarn run -T ts-node-transpile-only --project ./dev/tsconfig.json ./dev/server/production.server.ts",
"task:gulp": "yarn run -T cross-env NODE_OPTIONS=\"--max_old_space_size=8192\" gulp",
"task:gulp": "pnpm cross-env NODE_OPTIONS=\"--max_old_space_size=8192\" gulp",
"dev": "yarn task:gulp dev",
"unsafeDev": "yarn task:gulp unsafeDev",
"build": "yarn task:gulp build",
"build": "pnpm task:gulp build",
"watch": "yarn task:gulp watch",
"watch-webpack": "yarn task:gulp watchWebpack",
"webpack": "yarn task:gulp webpack",
Expand Down
4 changes: 4 additions & 0 deletions client/web/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ const config = {
// https://github.com/joshwnj/react-visibility-sensor/issues/148
'react-visibility-sensor': path.resolve(ROOT_PATH, 'node_modules/react-visibility-sensor/visibility-sensor.js'),
},
fallback: {
path: require.resolve('path-browserify'),
util: require.resolve('util/'),
},
Comment on lines +235 to +238
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Still not clear to be why I had to add these for pnpm.

Copy link

Choose a reason for hiding this comment

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

What does "fallback" do?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Something to do with redirecting imports if it's not found, which is useful for browserified node libraries (I think).

},
module: {
rules: [
Expand Down
50 changes: 33 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
},
"engines": {
"node": "^v16.7.0",
"yarn": "^1.22.4"
"pnpm": ">=7"
},
"scripts": {
"preinstall": "npx only-allow pnpm",
"format": "prettier '**/{*.{js?(on),ts?(x),graphql,md,scss},.*.js?(on)}' --write --list-different --config prettier.config.js",
"format:check": "yarn run format --write=false --check --list-different=false --loglevel=warn",
"_lint:js": "DOCSITE_LIST=\"$(./dev/docsite.sh -config doc/docsite.json ls)\" NODE_OPTIONS=\"--max_old_space_size=16192\" eslint",
Expand All @@ -22,7 +23,7 @@
"lint:css:all": "yarn _lint:css 'client/*/src/**/*.scss'",
"lint:graphql": "graphql-schema-linter",
"build-ts": "tsc -b tsconfig.all.json",
"build-web": "yarn workspace @sourcegraph/web run build",
"build-web": "pnpm -C client/web build",
"watch-web": "yarn workspace @sourcegraph/web run watch",
"generate": "gulp generate",
"watch-generate": "gulp watchGenerate",
Expand Down Expand Up @@ -86,12 +87,6 @@
"**/assets"
]
},
"workspaces": {
"packages": [
"client/*",
"dev/release"
]
},
"devDependencies": {
"@atlassian/aui": "^7.10.3",
"@axe-core/puppeteer": "^4.4.2",
Expand Down Expand Up @@ -373,9 +368,12 @@
"@microsoft/fetch-event-source": "^2.0.1",
"@opentelemetry/api": "^1.1.0",
"@opentelemetry/context-zone": "^1.5.0",
"@opentelemetry/core": "^1.7.0",
"@opentelemetry/exporter-trace-otlp-http": "^0.31.0",
"@opentelemetry/instrumentation": "^0.31.0",
"@opentelemetry/instrumentation-fetch": "^0.31.0",
"@opentelemetry/resources": "^1.7.0",
"@opentelemetry/sdk-trace-base": "^1.7.0",
Comment on lines +375 to +376
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If I added some new deps here, it's because they were being depended upon directly but were actually transitive deps before pnpm.

"@opentelemetry/sdk-trace-web": "^1.5.0",
"@opentelemetry/semantic-conventions": "^1.5.0",
"@reach/accordion": "^0.16.1",
Expand All @@ -387,17 +385,31 @@
"@reach/visually-hidden": "^0.16.0",
"@react-aria/live-announcer": "^3.1.0",
"@sentry/browser": "^7.8.1",
"@sourcegraph/branded": "workspace:*",
"@sourcegraph/build-config": "workspace:*",
"@sourcegraph/client-api": "workspace:*",
"@sourcegraph/codeintellify": "workspace:*",
"@sourcegraph/common": "workspace:*",
"@sourcegraph/extension-api-classes": "^1.1.0",
"@sourcegraph/http-client": "workspace:*",
"@sourcegraph/observability-client": "workspace:*",
"@sourcegraph/search": "workspace:*",
"@sourcegraph/search-ui": "workspace:*",
"@sourcegraph/shared": "workspace:*",
"@sourcegraph/template-parser": "workspace:*",
"@sourcegraph/wildcard": "workspace:*",
"@storybook/addon-controls": "^6.5.9",
"@storybook/addon-knobs": "^6.4.0",
"@types/react-resizable": "^3.0.2",
"@visx/annotation": "^2.10.0",
"@visx/axis": "^2.11.1",
"@visx/event": "^2.6.0",
"@visx/glyph": "^2.10.0",
"@visx/grid": "^2.10.0",
"@visx/group": "^2.10.0",
"@visx/responsive": "^2.10.0",
"@visx/scale": "^2.2.2",
"@visx/shape": "^2.12.2",
"@visx/voronoi": "^2.10.0",
"@vscode/codicons": "^0.0.29",
"@vscode/webview-ui-toolkit": "^0.9.0",
Expand All @@ -421,12 +433,14 @@
"downshift": "^3.4.8",
"escape-html": "^1.0.3",
"eventsource": "1.1.1",
"fast-json-stable-stringify": "^2.1.0",
"focus-visible": "^5.2.0",
"fzy.js": "^0.4.1",
"got": "^11.5.2",
"graphiql": "^1.11.5",
"highlight.js": "^10.5.0",
"highlightjs-graphql": "^1.0.2",
"history": "4.5.1",
"http-proxy-agent": "^5.0.0",
"http-status-codes": "^2.1.4",
"https-browserify": "^1.0.0",
Expand Down Expand Up @@ -491,13 +505,15 @@
"yaml-ast-parser": "^0.0.43",
"zustand": "^3.6.9"
},
"resolutions": {
"history": "4.5.1",
"cssnano": "4.1.10",
"webpack": "5",
"tslib": "2.1.0",
"prettier": "2.2.1",
"jsprim": "1.4.2"
},
"packageManager": "[email protected]"
"packageManager": "[email protected]",
"pnpm": {
"overrides": {
"cssnano": "4.1.10",
"webpack": "5",
"tslib": "2.1.0",
"prettier": "2.2.1",
"jsprim": "1.4.2",
"source-map": "^0.7.4"
}
}
}
Loading