Skip to content

Commit

Permalink
feat: support yarn >=2
Browse files Browse the repository at this point in the history
  • Loading branch information
adriencaccia committed Feb 11, 2022
1 parent d565c4e commit 8f831bb
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 12 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"bugs": "https://github.com/adriencaccia/serverless-analyze-bundle-plugin/issues",
"dependencies": {
"@babel/runtime": "^7.17.2"
"@babel/runtime": "^7.17.2",
"check-node-version": "^4.2.1"
},
"devDependencies": {
"@babel/cli": "^7.17.0",
Expand Down
28 changes: 18 additions & 10 deletions plugin/bundleVisualizer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import check from 'check-node-version';
import { exec } from 'child_process';
import { readdirSync, statSync } from 'fs';
import { join, parse } from 'path';
Expand Down Expand Up @@ -81,16 +82,23 @@ async function bundleVisualizer(this: ServerlessAnalyzeBundlePlugin): Promise<vo
return;
}

await pExec(
[
'node_modules/.bin/esbuild-visualizer',
'--metadata',
metafileName,
'--filename',
`${TEMP_DIR_LOCATION}/${functionName}.html`,
'--open',
].join(' '),
);
const commandArray = [
'--metadata',
metafileName,
'--filename',
`${TEMP_DIR_LOCATION}/${functionName}.html`,
'--open',
];

check({ yarn: '>=2' }, err => {
if (err !== null) {
commandArray.unshift('node_modules/.bin/esbuild-visualizer');
} else {
commandArray.unshift('yarn', 'esbuild-visualizer');
}

void pExec(commandArray.join(' '));
});
}

export default bundleVisualizer;
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"composite": true,
"plugins": [{ "transform": "@zerollup/ts-transform-paths" }],
"emitDeclarationOnly": true,
"allowSyntheticDefaultImports": true,
"outDir": "./dist/types"
},
"exclude": ["./dist"],
Expand Down
32 changes: 31 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2660,6 +2660,14 @@ chalk@^2.0.0:
escape-string-regexp "^1.0.5"
supports-color "^5.3.0"

chalk@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-3.0.0.tgz#3f73c2bf526591f574cc492c51e2456349f844e4"
integrity sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==
dependencies:
ansi-styles "^4.1.0"
supports-color "^7.1.0"

char-regex@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/char-regex/-/char-regex-1.0.2.tgz#d744358226217f981ed58f479b1d6bcc29545dcf"
Expand All @@ -2670,6 +2678,18 @@ chardet@^0.7.0:
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e"
integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==

check-node-version@^4.2.1:
version "4.2.1"
resolved "https://registry.yarnpkg.com/check-node-version/-/check-node-version-4.2.1.tgz#42f7e3c6e2427327b5c9080dae593d8997fe9a06"
integrity sha512-YYmFYHV/X7kSJhuN/QYHUu998n/TRuDe8UenM3+m5NrkiH670lb9ILqHIvBencvJc4SDh+XcbXMR4b+TtubJiw==
dependencies:
chalk "^3.0.0"
map-values "^1.0.1"
minimist "^1.2.0"
object-filter "^1.0.2"
run-parallel "^1.1.4"
semver "^6.3.0"

child-process-ext@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/child-process-ext/-/child-process-ext-2.1.1.tgz#f7cf4e68fef60c4c8ee911e1b402413191467dc3"
Expand Down Expand Up @@ -5539,6 +5559,11 @@ map-obj@^4.0.0:
resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-4.3.0.tgz#9304f906e93faae70880da102a9f1df0ea8bb05a"
integrity sha512-hdN1wVrZbb29eBGiGjJbeP8JbKjq1urkHJ/LIP/NY48MZ1QVXUsQBV1G1zvYFHn1XE06cwjBsOI2K3Ulnj1YXQ==

map-values@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/map-values/-/map-values-1.0.1.tgz#768b8e79c009bf2b64fee806e22a7b1c4190c990"
integrity sha1-douOecAJvytk/ugG4ip7HEGQyZA=

memoizee@^0.4.14, memoizee@^0.4.15:
version "0.4.15"
resolved "https://registry.yarnpkg.com/memoizee/-/memoizee-0.4.15.tgz#e6f3d2da863f318d02225391829a6c5956555b72"
Expand Down Expand Up @@ -5801,6 +5826,11 @@ object-assign@^4.0.1:
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=

object-filter@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/object-filter/-/object-filter-1.0.2.tgz#af0b797ffebeaf8a52c6637cedbe8816cfec1bc8"
integrity sha1-rwt5f/6+r4pSxmN87b6IFs/sG8g=

object-hash@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/object-hash/-/object-hash-2.2.0.tgz#5ad518581eefc443bd763472b8ff2e9c2c0d54a5"
Expand Down Expand Up @@ -6529,7 +6559,7 @@ run-parallel-limit@^1.1.0:
dependencies:
queue-microtask "^1.2.2"

run-parallel@^1.1.9:
run-parallel@^1.1.4, run-parallel@^1.1.9:
version "1.2.0"
resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee"
integrity sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==
Expand Down

0 comments on commit 8f831bb

Please sign in to comment.