@rollup/plugin-node-resolve 13.0.1 → 13.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @rollup/plugin-node-resolve ChangeLog
2
2
 
3
+ ## v13.0.2
4
+
5
+ _2021-07-15_
6
+
7
+ ### Bugfixes
8
+
9
+ - fix
10
+
3
11
  ## v13.0.1
4
12
 
5
13
  _2021-07-15_
@@ -443,4 +451,4 @@ This release caches reading/statting of files, to improve speed.
443
451
 
444
452
  ## 0.1.0
445
453
 
446
- - First release
454
+ - First release
package/dist/cjs/index.js CHANGED
@@ -21,14 +21,15 @@ var isModule__default = /*#__PURE__*/_interopDefaultLegacy(isModule);
21
21
  var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
22
22
  var resolve__default = /*#__PURE__*/_interopDefaultLegacy(resolve);
23
23
 
24
- const access = util.promisify(fs__default['default'].access);
24
+ util.promisify(fs__default['default'].access);
25
25
  const readFile$1 = util.promisify(fs__default['default'].readFile);
26
26
  const realpath = util.promisify(fs__default['default'].realpath);
27
27
  const stat = util.promisify(fs__default['default'].stat);
28
- async function exists(filePath) {
28
+
29
+ async function fileExists(filePath) {
29
30
  try {
30
- await access(filePath);
31
- return true;
31
+ const res = await stat(filePath);
32
+ return res.isFile();
32
33
  } catch {
33
34
  return false;
34
35
  }
@@ -251,8 +252,6 @@ function normalizeInput(input) {
251
252
 
252
253
  /* eslint-disable no-await-in-loop */
253
254
 
254
- const fileExists = util.promisify(fs__default['default'].exists);
255
-
256
255
  function isModuleDir(current, moduleDirs) {
257
256
  return moduleDirs.some((dir) => current.endsWith(dir));
258
257
  }
@@ -566,7 +565,7 @@ async function getPackageJson(importer, pkgName, resolveOptions, moduleDirectori
566
565
  try {
567
566
  const pkgJsonPath = await resolveImportPath(`${pkgName}/package.json`, resolveOptions);
568
567
  const pkgJson = JSON.parse(await readFile(pkgJsonPath, 'utf-8'));
569
- return { pkgJsonPath, pkgJson };
568
+ return { pkgJsonPath, pkgJson, pkgPath: path.dirname(pkgJsonPath) };
570
569
  } catch (_) {
571
570
  return null;
572
571
  }
@@ -654,12 +653,11 @@ async function resolveId({
654
653
  const result = await getPackageJson(importer, pkgName, resolveOptions, moduleDirectories);
655
654
 
656
655
  if (result && result.pkgJson.exports) {
657
- const { pkgJson, pkgJsonPath } = result;
656
+ const { pkgJson, pkgJsonPath, pkgPath } = result;
658
657
  try {
659
658
  const subpath =
660
659
  pkgName === importSpecifier ? '.' : `.${importSpecifier.substring(pkgName.length)}`;
661
- const pkgDr = pkgJsonPath.replace('package.json', '');
662
- const pkgURL = url.pathToFileURL(pkgDr);
660
+ const pkgURL = url.pathToFileURL(`${pkgPath}/`);
663
661
 
664
662
  const context = {
665
663
  importer,
@@ -697,7 +695,7 @@ async function resolveId({
697
695
  }
698
696
 
699
697
  if (!preserveSymlinks) {
700
- if (await exists(location)) {
698
+ if (await fileExists(location)) {
701
699
  location = await realpath(location);
702
700
  }
703
701
  }
@@ -1007,8 +1005,8 @@ function nodeResolve(opts = {}) {
1007
1005
  }
1008
1006
 
1009
1007
  if (hasPackageEntry && !preserveSymlinks) {
1010
- const fileExists = await exists(location);
1011
- if (fileExists) {
1008
+ const exists = await fileExists(location);
1009
+ if (exists) {
1012
1010
  location = await realpath(location);
1013
1011
  }
1014
1012
  }
@@ -1028,7 +1026,7 @@ function nodeResolve(opts = {}) {
1028
1026
  }
1029
1027
  }
1030
1028
 
1031
- if (options.modulesOnly && (await exists(location))) {
1029
+ if (options.modulesOnly && (await fileExists(location))) {
1032
1030
  const code = await readFile$1(location, 'utf-8');
1033
1031
  if (isModule__default['default'](code)) {
1034
1032
  return {
package/dist/es/index.js CHANGED
@@ -8,14 +8,15 @@ import { pathToFileURL, fileURLToPath } from 'url';
8
8
  import resolve$1 from 'resolve';
9
9
  import { createFilter } from '@rollup/pluginutils';
10
10
 
11
- const access = promisify(fs.access);
11
+ promisify(fs.access);
12
12
  const readFile$1 = promisify(fs.readFile);
13
13
  const realpath = promisify(fs.realpath);
14
14
  const stat = promisify(fs.stat);
15
- async function exists(filePath) {
15
+
16
+ async function fileExists(filePath) {
16
17
  try {
17
- await access(filePath);
18
- return true;
18
+ const res = await stat(filePath);
19
+ return res.isFile();
19
20
  } catch {
20
21
  return false;
21
22
  }
@@ -238,8 +239,6 @@ function normalizeInput(input) {
238
239
 
239
240
  /* eslint-disable no-await-in-loop */
240
241
 
241
- const fileExists = promisify(fs.exists);
242
-
243
242
  function isModuleDir(current, moduleDirs) {
244
243
  return moduleDirs.some((dir) => current.endsWith(dir));
245
244
  }
@@ -553,7 +552,7 @@ async function getPackageJson(importer, pkgName, resolveOptions, moduleDirectori
553
552
  try {
554
553
  const pkgJsonPath = await resolveImportPath(`${pkgName}/package.json`, resolveOptions);
555
554
  const pkgJson = JSON.parse(await readFile(pkgJsonPath, 'utf-8'));
556
- return { pkgJsonPath, pkgJson };
555
+ return { pkgJsonPath, pkgJson, pkgPath: dirname(pkgJsonPath) };
557
556
  } catch (_) {
558
557
  return null;
559
558
  }
@@ -641,12 +640,11 @@ async function resolveId({
641
640
  const result = await getPackageJson(importer, pkgName, resolveOptions, moduleDirectories);
642
641
 
643
642
  if (result && result.pkgJson.exports) {
644
- const { pkgJson, pkgJsonPath } = result;
643
+ const { pkgJson, pkgJsonPath, pkgPath } = result;
645
644
  try {
646
645
  const subpath =
647
646
  pkgName === importSpecifier ? '.' : `.${importSpecifier.substring(pkgName.length)}`;
648
- const pkgDr = pkgJsonPath.replace('package.json', '');
649
- const pkgURL = pathToFileURL(pkgDr);
647
+ const pkgURL = pathToFileURL(`${pkgPath}/`);
650
648
 
651
649
  const context = {
652
650
  importer,
@@ -684,7 +682,7 @@ async function resolveId({
684
682
  }
685
683
 
686
684
  if (!preserveSymlinks) {
687
- if (await exists(location)) {
685
+ if (await fileExists(location)) {
688
686
  location = await realpath(location);
689
687
  }
690
688
  }
@@ -994,8 +992,8 @@ function nodeResolve(opts = {}) {
994
992
  }
995
993
 
996
994
  if (hasPackageEntry && !preserveSymlinks) {
997
- const fileExists = await exists(location);
998
- if (fileExists) {
995
+ const exists = await fileExists(location);
996
+ if (exists) {
999
997
  location = await realpath(location);
1000
998
  }
1001
999
  }
@@ -1015,7 +1013,7 @@ function nodeResolve(opts = {}) {
1015
1013
  }
1016
1014
  }
1017
1015
 
1018
- if (options.modulesOnly && (await exists(location))) {
1016
+ if (options.modulesOnly && (await fileExists(location))) {
1019
1017
  const code = await readFile$1(location, 'utf-8');
1020
1018
  if (isModule(code)) {
1021
1019
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rollup/plugin-node-resolve",
3
- "version": "13.0.1",
3
+ "version": "13.0.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -25,15 +25,16 @@
25
25
  },
26
26
  "scripts": {
27
27
  "build": "rollup -c",
28
- "ci:coverage": "nyc pnpm run test && nyc report --reporter=text-lcov > coverage.lcov",
29
- "ci:lint": "pnpm run build && pnpm run lint",
28
+ "ci:coverage": "nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov",
29
+ "ci:lint": "pnpm build && pnpm lint",
30
30
  "ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",
31
- "ci:test": "pnpm run test -- --verbose && pnpm run test:ts",
31
+ "ci:test": "pnpm test -- --verbose && pnpm test:ts",
32
32
  "prebuild": "del-cli dist",
33
- "prepare": "pnpm run build",
34
- "prepublishOnly": "pnpm -w run lint && pnpm run test && pnpm run test:ts",
35
- "pretest": "pnpm run build",
36
- "test": "ava",
33
+ "prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
34
+ "prerelease": "pnpm build",
35
+ "pretest": "pnpm build",
36
+ "release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
37
+ "test": "ava && pnpm test:ts",
37
38
  "test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
38
39
  },
39
40
  "files": [