Skip to content

feat(cli): use --prefer-local option to link external `node_modules#1117

Merged
antonmedv merged 3 commits intogoogle:mainfrom
antongolub:nm-link
Mar 2, 2025
Merged

feat(cli): use --prefer-local option to link external `node_modules#1117
antonmedv merged 3 commits intogoogle:mainfrom
antongolub:nm-link

Conversation

@antongolub
Copy link
Collaborator

@antongolub antongolub commented Mar 2, 2025

closes #1116

const cwd = tmpdir()
const external = tmpdir()
await fs.outputJson(path.join(external, 'node_modules/a/package.json'), {
  name: 'a',
  version: '1.0.0',
  type: 'module',
  exports: './index.js',
})
await fs.outputFile(
  path.join(external, 'node_modules/a/index.js'),
  `
export const a = 'AAA'
`
)
const script = `
import {a} from 'a'
console.log(a);
`
const out =
  await $`node build/cli.js --cwd=${cwd} --prefer-local=${external} --test <<< ${script}`
assert.equal(out.stdout, 'AAA\n')
  • Tests pass
  • Appropriate changes to README are included in PR

@antongolub antongolub requested a review from antonmedv March 2, 2025 14:15
@antonmedv antonmedv merged commit 539130a into google:main Mar 2, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a flag to include a user defined node_modules location.

2 participants