mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-25 10:31:55 -04:00
fix: packages can require themself
node_modules structure changed
This commit is contained in:
18
README.md
18
README.md
@@ -36,13 +36,13 @@ See [store layout](docs/store-layout.md) for an explanation.
|
||||
-> - a symlink (or junction on Windows)
|
||||
|
||||
~/.store
|
||||
├─ chalk/1.1.1/
|
||||
├─ chalk/1.1.1/node_modules/chalk/
|
||||
| ├─ index.js
|
||||
| └─ package.json
|
||||
├─ ansi-styles/2.1.0/
|
||||
├─ ansi-styles/2.1.0/node_modules/chalk/
|
||||
| ├─ index.js
|
||||
| └─ package.json
|
||||
└─ has-ansi/2.0.0/
|
||||
└─ has-ansi/2.0.0/node_modules/chalk/
|
||||
├─ index.js
|
||||
└─ package.json
|
||||
.
|
||||
@@ -52,14 +52,14 @@ See [store layout](docs/store-layout.md) for an explanation.
|
||||
| | ├─ node_modules/
|
||||
| | | ├─ ansi-styles/ -> ../../ansi-styles/2.1.0/
|
||||
| | | └─ has-ansi/ -> ../../has-ansi/2.0.0/
|
||||
| | ├─ index.js => ~/.store/chalk/1.1.1/index.js
|
||||
| | └─ package.json => ~/.store/chalk/1.1.1/package.json
|
||||
| | ├─ index.js => ~/.store/chalk/1.1.1/node_modules/chalk/index.js
|
||||
| | └─ package.json => ~/.store/chalk/1.1.1/node_modules/chalk/package.json
|
||||
| ├─ has-ansi/2.0.0/
|
||||
| | ├─ index.js => ~/.store/has-ansi/2.0.0/index.js
|
||||
| | └─ package.js => ~/.store/has-ansi/2.0.0/package.json
|
||||
| | ├─ index.js => ~/.store/has-ansi/2.0.0/node_modules/has-ansi/index.js
|
||||
| | └─ package.js => ~/.store/has-ansi/2.0.0/node_modules/has-ansi/package.json
|
||||
| └─ ansi-styles/2.1.0/
|
||||
| ├─ index.js => ~/.store/ansi-styles/2.1.0/index.js
|
||||
| └─ package.js => ~/.store/ansi-styles/2.1.0/package.json
|
||||
| ├─ index.js => ~/.store/ansi-styles/2.1.0/node_modules/ansi-styles/index.js
|
||||
| └─ package.js => ~/.store/ansi-styles/2.1.0/node_modules/ansi-styles/package.json
|
||||
└─ chalk/ -> ./.resolutions/chalk/1.1.1/
|
||||
```
|
||||
|
||||
|
||||
@@ -118,7 +118,9 @@ async function install (pkgRawSpec: string, modules: string, ctx: InstallContext
|
||||
optional: options.optional === true,
|
||||
pkg,
|
||||
// TODO: what about bundled/cached deps?
|
||||
hardlinkedLocation: path.join(options.nodeModulesStore, fetchedPkg.id),
|
||||
// The package realpath should be under node_modules/<pkgname>. This way, babel-runtime@5 can
|
||||
// require('babel-runtime') within itself.
|
||||
hardlinkedLocation: path.join(options.nodeModulesStore, fetchedPkg.id, 'node_modules', pkg.name),
|
||||
})
|
||||
|
||||
if (dependency.fromCache || keypath.indexOf(dependency.id) !== -1) {
|
||||
|
||||
@@ -841,3 +841,11 @@ test('shrinkwrap locks npm dependencies', async function (t) {
|
||||
|
||||
t.equal(pkg.version, '100.0.0', 'dependency specified in shrinkwrap.yaml is installed')
|
||||
})
|
||||
|
||||
test('self-require should work', async function (t) {
|
||||
const project = prepare(t)
|
||||
|
||||
await installPkgs(['uses-pkg-with-self-usage'], testDefaults())
|
||||
|
||||
t.ok(project.requireModule('uses-pkg-with-self-usage'))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user