diff --git a/package.json b/package.json index f965d8a..8314457 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ }, "optimize": true, "includeNodeModules": true, - "outputFormat": "global", + "outputFormat": "esmodule", "isLibrary": true }, "module.browser": { @@ -101,6 +101,7 @@ "prettier": "prettier-config-atomic", "dependencies": { "escape-string-regexp": "^5.0.0", + "is-path-inside": "^4.0.0", "replace-ext": "^2.0.0" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 384529f..d70be07 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -19,6 +19,7 @@ importers: escape-string-regexp: ^5.0.0 eslint: ^8.21.0 eslint-config-atomic: ^1.18.1 + is-path-inside: ^4.0.0 jest: ^28.1.3 npm-check-updates: ^16.0.5 npm-run-all2: ^6.0.1 @@ -36,6 +37,7 @@ importers: typescript: ^4.7.4 dependencies: escape-string-regexp: 5.0.0 + is-path-inside: 4.0.0 replace-ext: 2.0.0 optionalDependencies: '@types/node': 18.6.3 @@ -5065,6 +5067,11 @@ packages: engines: {node: '>=8'} dev: true + /is-path-inside/4.0.0: + resolution: {integrity: sha512-lJJV/5dYS+RcL8uQdBDW9c9uWFLLBNRyFhnAKXw5tVqLlKZ4RMGZKv+YQ/IA3OhD+RpbJa1LLFM1FQPGyIXvOA==} + engines: {node: '>=12'} + dev: false + /is-plain-obj/2.1.0: resolution: {integrity: sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==} engines: {node: '>=8'} diff --git a/src/is-path-inside.ts b/src/is-path-inside.ts index 541104c..9980951 100644 --- a/src/is-path-inside.ts +++ b/src/is-path-inside.ts @@ -1,4 +1,4 @@ -import { relative, resolve, sep } from "path" +import { default as isPathInsideOrig } from "is-path-inside" /** * Check if a path is inside another path. @@ -26,9 +26,5 @@ import { relative, resolve, sep } from "path" * ``` */ export function isPathInside(childPath: string, parentPath: string): boolean { - // copied from is-path-inside because the package uses node:path that can't be bundled for the browser - - const relation = relative(parentPath, childPath) - - return Boolean(relation && relation !== ".." && !relation.startsWith(`..${sep}`) && relation !== resolve(childPath)) + return isPathInsideOrig(childPath, parentPath) }