Repository navigation
chore: Use the isolated pnpm node_modules layout #25368
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
Changes from all commits
279d65a
3b02d7c
cba3ddb
5f5b7a9
e73ba06
26a1ddf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4,7 +4,7 @@ import { cp, mkdir, readFile, rm, writeFile } from 'fs/promises'; | |||||
| import { basename, join } from 'path'; | ||||||
|
Member
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.
Suggested change
|
||||||
| import { promisify } from 'util'; | ||||||
| import { afterAll, beforeAll, test, type TestAPI } from 'vitest'; | ||||||
| import { CLEANUP_STEPS, createRunner } from './createRunner'; | ||||||
| import { CLEANUP_STEPS, createRunner, PACKAGE_ROOT } from './createRunner'; | ||||||
|
|
||||||
| const execPromise = promisify(exec); | ||||||
|
|
||||||
|
|
@@ -267,7 +267,10 @@ function prepareTmpDir( | |||||
| } | ||||||
|
|
||||||
| if (options?.afterSetupCommand) { | ||||||
| const env = { ...process.env, PATH: `${join(tmpDirPath, 'node_modules', '.bin')}:${process.env.PATH}` }; | ||||||
| // The Bun and Deno packages run these suites with their own `PATH`, which does not have the bins of | ||||||
| // this package (e.g. `prisma`). | ||||||
| const binPaths = [join(tmpDirPath, 'node_modules', '.bin'), join(PACKAGE_ROOT, 'node_modules', '.bin')]; | ||||||
| const env = { ...process.env, PATH: `${binPaths.join(':')}:${process.env.PATH}` }; | ||||||
|
Member
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.
Suggested change
|
||||||
| await execPromise(options.afterSetupCommand, { cwd: tmpDirPath, env }); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,18 +44,29 @@ function isSideEffectFreePackage(packageName) { | |
|
|
||
| let sideEffectFree = false; | ||
| try { | ||
| const json = JSON.parse( | ||
| fs.readFileSync(path.resolve(repoRoot, 'node_modules', packageName, 'package.json'), { encoding: 'utf8' }), | ||
| ); | ||
| const json = JSON.parse(fs.readFileSync(findPackageJson(packageName), { encoding: 'utf8' })); | ||
| sideEffectFree = json.sideEffects === false; | ||
| } catch { | ||
| // Not resolvable from the repo root - assume side effects. | ||
| // Not resolvable from the built package - assume side effects. | ||
|
Member
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.
The commit message says this exact fallback caused leftover Suggestion: log a warning in the |
||
| } | ||
|
|
||
| sideEffectsCache.set(packageName, sideEffectFree); | ||
| return sideEffectFree; | ||
| } | ||
|
|
||
| /** | ||
| * The `package.json` of a dependency of the built package (the working directory): the nearest | ||
| * `node_modules/<packageName>` from there up to the repo root, like Node resolves it. | ||
| */ | ||
| function findPackageJson(packageName) { | ||
| for (let dir = process.cwd(); ; dir = path.dirname(dir)) { | ||
| const candidate = path.join(dir, 'node_modules', packageName, 'package.json'); | ||
| if (fs.existsSync(candidate) || dir === repoRoot || dir === path.dirname(dir)) { | ||
| return candidate; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| function getPackageName(id) { | ||
| const segments = id.split('/'); | ||
| return id.startsWith('@') ? segments.slice(0, 2).join('/') : segments[0]; | ||
|
|
||
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.
Thinking this should probably match the lockfile and
@sentry/bundler-pluginsdeps, yeah?