ITADN

v0.6.0 introduced regression in Node package resolution

#244Closednolanlawson 创建于 2022-08-25
N
nolanlawsoncommented
Hi, thanks again for all the work you've put into Tachometer! I want to raise an issue that seems to have been introduced in 0.6.0 (dfd623f0efe86413b957460eb15000d532af3972). Before 0.6.0, if you did something like this in a JS file: ```js import 'some-package-from-npm` ``` ...then it would work even if the `tachometer.json` config file was not located at the root of the project. However, starting with 0.6.0, this resolution fails when running locally, presumably because the `./node_modules` resolution is now relative to the `tachometer.json` file rather than the CWD. Here is [a minimal repro](https://github.com/nolanlawson/tachometer-repro-package-import-issue). Note the `tachometer.json` file is in a subdirectory (`dir`), and the `benchmark.html` file is unable to do `import normalizeUrl from "normalize-url"` – the file gives a 404: ![Screen Shot 2022-08-25 at 2 23 13 PM](https://user-images.githubusercontent.com/283842/186772402-0424b7e5-ebfe-4b74-b23d-8fea733a9941.png) (Note I chose `normalize-url` essentially at random; any npm package should fail in the same way.) This may be a special case of #215. Walking up the directory to try to find matches for `node_modules/<name of package>` (i.e. implementing module resolution the way Node does it) should fix this issue.
关闭于 2024-08-03 2 条评论