Skip to content

Commit

Permalink
fix: pnpm was not bundling externals correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
floydspace committed Dec 31, 2022
1 parent 203dc7a commit 5bfaee0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
6 changes: 5 additions & 1 deletion e2e/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test-e2e: test-e2e-minimal test-e2e-individually test-e2e-complete
test-e2e: test-e2e-minimal test-e2e-individually test-e2e-complete test-e2e-config

build:
npm run build
Expand All @@ -23,3 +23,7 @@ test-e2e-complete: build
cd ./.test-artifacts/complete/.serverless && unzip complete-example.zip
npx jest -c jest.config.e2e.js --ci ./e2e/complete.test.ts
rm -fr ./.test-artifacts

test-e2e-config: build
rm -fr ./.test-artifacts && mkdir -p ./.test-artifacts/config && rsync -r ./examples/config/ ./.test-artifacts/config/
cd ./.test-artifacts/config && pnpm install && npx sls package
2 changes: 1 addition & 1 deletion examples/config/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = () => {
return {
packager: 'npm',
packager: 'pnpm',
bundle: true,
minify: true,
sourcemap: false,
Expand Down
1 change: 1 addition & 0 deletions src/packagers/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ export class NPM implements Packager {

async install(cwd: string, extraArgs: Array<string>) {
const command = /^win/.test(process.platform) ? 'npm.cmd' : 'npm';

const args = ['install', ...extraArgs];

await spawnProcess(command, args, { cwd });
Expand Down
6 changes: 3 additions & 3 deletions src/packagers/pnpm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class Pnpm implements Packager {
const processOutput = await spawnProcess(command, args, { cwd });
const depJson = processOutput.stdout;

return JSON.parse(depJson);
return JSON.parse(depJson)[0];
} catch (err) {
if (err instanceof SpawnError) {
// Only exit with an error if we have critical npm errors for 2nd level inside
Expand Down Expand Up @@ -89,10 +89,10 @@ export class Pnpm implements Packager {
return lockfile;
}

async install(cwd: string, extraArgs: string[], useLockfile = true) {
async install(cwd: string, extraArgs: Array<string>) {
const command = /^win/.test(process.platform) ? 'pnpm.cmd' : 'pnpm';

const args = useLockfile ? ['install', '--frozen-lockfile', ...extraArgs] : ['install', ...extraArgs];
const args = ['install', ...extraArgs];

await spawnProcess(command, args, { cwd });
}
Expand Down
1 change: 1 addition & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export const findProjectRoot = (rootDir?: string) =>
pipe(
IOO.fromNullable(rootDir),
IOO.fold(() => findUpIO('yarn.lock'), IOO.of),
IOO.fold(() => findUpIO('pnpm-lock.yaml'), IOO.of),
IOO.fold(() => findUpIO('package-lock.json'), IOO.of),
IOO.toUndefined
)();
Expand Down

0 comments on commit 5bfaee0

Please sign in to comment.