@ms-cloudpack/bundler-plugin-webpack
Advanced tools
Comparing version 0.2.4 to 0.2.5
/** | ||
* Resolves the paths of the provided modules. | ||
* @param modules - The modules to resolve. | ||
* Resolves the paths of the provided modules relative to the bundler-plugin-webpack package, | ||
* and returns a list of unique containing folders which webpack can use as module search paths. | ||
* @param modules - The modules to resolve. Must be dependencies of this package. | ||
* @returns - Containing folders of the modules. (ie: /path/to/node_modules/) | ||
@@ -5,0 +6,0 @@ */ |
@@ -1,23 +0,11 @@ | ||
import { createRequire } from 'module'; | ||
import path from 'path'; | ||
const safeRequire = createRequire(import.meta.url); | ||
function findContainingFolder(filePath, folderName) { | ||
// Resolve the provided file path to an absolute path | ||
const absolutePath = path.resolve(filePath); | ||
// Split the path into an array of directories | ||
const pathParts = absolutePath.split(path.sep); | ||
// Find the index of the provided folder name in the path parts | ||
const folderIndex = pathParts.indexOf(folderName); | ||
// If the folder name is found and it's not the last part of the path, | ||
// return the path of the parent directory | ||
if (folderIndex !== -1 && folderIndex < pathParts.length - 1) { | ||
const parentFolder = path.join(...pathParts.slice(0, folderIndex)); | ||
return parentFolder; | ||
} | ||
// If the folder name is not found or it's the last part of the path, | ||
return undefined; | ||
} | ||
import { moduleResolve } from 'import-meta-resolve'; | ||
import { fileURLToPath } from 'url'; | ||
import { findPackageRoot } from '@ms-cloudpack/path-utilities'; | ||
const conditions = new Set(['node', 'require', 'import', 'default']); | ||
const resolveFrom = new URL(import.meta.url); | ||
/** | ||
* Resolves the paths of the provided modules. | ||
* @param modules - The modules to resolve. | ||
* Resolves the paths of the provided modules relative to the bundler-plugin-webpack package, | ||
* and returns a list of unique containing folders which webpack can use as module search paths. | ||
* @param modules - The modules to resolve. Must be dependencies of this package. | ||
* @returns - Containing folders of the modules. (ie: /path/to/node_modules/) | ||
@@ -28,5 +16,8 @@ */ | ||
for (const moduleName of modules) { | ||
const modulePath = findContainingFolder(safeRequire.resolve(moduleName), moduleName); | ||
if (modulePath) { | ||
paths.add(modulePath); | ||
// Resolve the module path and find the package root from there. | ||
// preserveSymlinks ensures we get the path where it's installed as a dependency, not from the store. | ||
const modulePath = moduleResolve(moduleName, resolveFrom, conditions, true /*preserveSymlinks*/); | ||
const packageRoot = findPackageRoot(fileURLToPath(modulePath)); | ||
if (packageRoot) { | ||
paths.add(path.dirname(packageRoot)); | ||
} | ||
@@ -33,0 +24,0 @@ } |
{ | ||
"name": "@ms-cloudpack/bundler-plugin-webpack", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "A cloudpack plugin for abstracting webpack.", | ||
@@ -17,9 +17,11 @@ "license": "MIT", | ||
"dependencies": { | ||
"@ms-cloudpack/bundler-types": "^0.25.1", | ||
"@ms-cloudpack/esm-stub-utilities": "^0.10.10", | ||
"@ms-cloudpack/package-utilities": "^6.0.1", | ||
"@ms-cloudpack/bundler-types": "^0.25.2", | ||
"@ms-cloudpack/esm-stub-utilities": "^0.10.11", | ||
"@ms-cloudpack/package-utilities": "^6.0.2", | ||
"@ms-cloudpack/path-string-parsing": "^1.2.1", | ||
"@ms-cloudpack/path-utilities": "^2.6.1", | ||
"@ms-cloudpack/worker-pool": "^0.1.1", | ||
"@swc/core": "^1.4.0", | ||
"css-loader": "^6.0.0", | ||
"import-meta-resolve": "^4.0.0", | ||
"resolve-typescript-plugin": "^2.0.0", | ||
@@ -26,0 +28,0 @@ "sass": "^1.0.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
1
32615
17
297
+ Addedimport-meta-resolve@^4.0.0
+ Added@swc/core@1.10.12(transitive)
+ Added@swc/core-darwin-arm64@1.10.12(transitive)
+ Added@swc/core-darwin-x64@1.10.12(transitive)
+ Added@swc/core-linux-arm-gnueabihf@1.10.12(transitive)
+ Added@swc/core-linux-arm64-gnu@1.10.12(transitive)
+ Added@swc/core-linux-arm64-musl@1.10.12(transitive)
+ Added@swc/core-linux-x64-gnu@1.10.12(transitive)
+ Added@swc/core-linux-x64-musl@1.10.12(transitive)
+ Added@swc/core-win32-arm64-msvc@1.10.12(transitive)
+ Added@swc/core-win32-ia32-msvc@1.10.12(transitive)
+ Added@swc/core-win32-x64-msvc@1.10.12(transitive)
+ Added@types/node@22.13.0(transitive)
+ Addedcaniuse-lite@1.0.30001696(transitive)
+ Addedelectron-to-chromium@1.5.90(transitive)
+ Addedenhanced-resolve@5.18.0(transitive)
+ Addedsass@1.83.4(transitive)
+ Addedsemver@7.7.0(transitive)
+ Addedterser@5.37.0(transitive)
- Removed@swc/core@1.10.14(transitive)
- Removed@swc/core-darwin-arm64@1.10.14(transitive)
- Removed@swc/core-darwin-x64@1.10.14(transitive)
- Removed@swc/core-linux-arm-gnueabihf@1.10.14(transitive)
- Removed@swc/core-linux-arm64-gnu@1.10.14(transitive)
- Removed@swc/core-linux-arm64-musl@1.10.14(transitive)
- Removed@swc/core-linux-x64-gnu@1.10.14(transitive)
- Removed@swc/core-linux-x64-musl@1.10.14(transitive)
- Removed@swc/core-win32-arm64-msvc@1.10.14(transitive)
- Removed@swc/core-win32-ia32-msvc@1.10.14(transitive)
- Removed@swc/core-win32-x64-msvc@1.10.14(transitive)
- Removed@types/node@22.13.1(transitive)
- Removedcaniuse-lite@1.0.30001698(transitive)
- Removedelectron-to-chromium@1.5.96(transitive)
- Removedenhanced-resolve@5.18.1(transitive)
- Removedsass@1.84.0(transitive)
- Removedsemver@7.7.1(transitive)
- Removedterser@5.38.1(transitive)