Skip to content

Commit

Permalink
Merge pull request #336 from codingnuclei/bugfix/packagePath_usage_co…
Browse files Browse the repository at this point in the history
…nsistent

fix: packagePath correctly treated as relative path from service dir
  • Loading branch information
floydspace committed Jul 18, 2022
2 parents 2c1d2ac + 56e6dd8 commit 812a77e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/pack-externals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function getProdModules(
packageJsonPath: string,
rootPackageJsonPath: string
) {
const packageJson = require(packageJsonPath);
const packageJson = this.serverless.utils.readFileSync(packageJsonPath);
const prodModules = [];

// only process the module stated in dependencies section
Expand Down Expand Up @@ -132,6 +132,7 @@ function getProdModules(
'package.json'
);
const localModulePackagePath = path.join(
process.cwd(),
path.dirname(packageJsonPath),
'node_modules',
externalModule.external,
Expand Down Expand Up @@ -308,7 +309,11 @@ export async function packExternalModules(this: EsbuildServerlessPlugin) {
);

// (1.a.2) Copy package-lock.json if it exists, to prevent unwanted upgrades
const packageLockPath = path.join(path.dirname(packageJsonPath), packager.lockfileName);
const packageLockPath = path.join(
process.cwd(),
path.dirname(packageJsonPath),
packager.lockfileName
);
const exists = await fse.pathExists(packageLockPath);
if (exists) {
this.log.verbose('Package lock found - Using locked versions');
Expand Down

0 comments on commit 812a77e

Please sign in to comment.