Skip to content

Commit 253c329

Browse files
author
John Simons
authored
Merge pull request #235 from OctopusDeploy/john/minify
2 parents a438d77 + d968002 commit 253c329

File tree

4 files changed

+335
-501
lines changed

4 files changed

+335
-501
lines changed

esbuild.mjs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { build } from "esbuild";
22
import { cleanPlugin } from "esbuild-clean-plugin";
3-
import { esbuildPluginNodeExternals } from "esbuild-plugin-node-externals";
43
import copyStaticFiles from "esbuild-copy-static-files";
54
import glob from "glob";
65
import { sep } from "path";
@@ -54,13 +53,26 @@ function noFolders(src) {
5453
return !isDirectory;
5554
}
5655

56+
const bundleAsMuchAsWeCan = {
57+
name: 'my-special-bundle',
58+
setup(build) {
59+
build.onResolve( { filter: /^[^.\/]|^\.[^.\/]|^\.\.[^\/]/ } , args => {
60+
console.log(args.path);
61+
console.log(`args.resolveDir=${args.resolveDir}`);
62+
if(args.path.startsWith("azure-pipelines-tool-lib") || args.path.startsWith( "azure-pipelines-task-lib"))
63+
return { path: args.path, external: true };
64+
})
65+
},
66+
}
67+
5768
build({
5869
entryPoints: entryPoints(),
5970
bundle: true,
6071
target: "es2018",
6172
platform: "node",
6273
outdir: "dist",
6374
metafile: true,
75+
minify: true,
6476
plugins: [
6577
cleanPlugin(),
6678
copyStaticFiles({ src: "./source/img", dest: "dist/img" }),
@@ -69,7 +81,7 @@ build({
6981
copyStaticFiles({ src: "./node_modules/vss-web-extension-sdk/lib", dest: "dist/widgets/ProjectStatus/lib" }),
7082
copyStaticFiles({ src: "./source/tasks", dest: "dist/tasks", filter: noTSFiles }),
7183
copyStaticFiles({ src: "./source/tasksLegacy", dest: "dist/tasks", filter: noTSFiles }),
72-
esbuildPluginNodeExternals(),
84+
bundleAsMuchAsWeCan
7385
],
7486
logLimit: 0,
7587
logLevel: "info",

pack.ps1

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,25 @@ function UpdateTaskManifests($workingDirectory, $version, $envName) {
5555
}
5656

5757
function SetupTaskDependencies($workingDirectory) {
58-
& npm prune --production
58+
$tempPath = "$basePath/modules";
5959

60+
mkdir "$tempPath/node_modules"
61+
& npm install --prefix $tempPath azure-pipelines-task-lib azure-pipelines-tool-lib
62+
& npm dedup --prefix $tempPath
6063
& go install github.com/tj/node-prune@latest
6164

6265
$goPath = go env GOPATH
6366
$command = "$goPath/bin/node-prune"
6467

65-
Invoke-Expression "$command ./node_modules"
68+
Invoke-Expression "$command $tempPath/node_modules"
6669

6770
$taskManifestFiles = Get-ChildItem $workingDirectory -Include "task.json" -Recurse
6871

6972
foreach ($manifestFile in $taskManifestFiles) {
7073
$directory = Split-Path -parent $manifestFile
7174

72-
mkdir "$directory/node_modules"
73-
Copy-Item -Path "./node_modules/*" -Destination "$directory/node_modules" -Recurse
75+
New-Item -ItemType Directory -Path "$directory/node_modules"
76+
Copy-Item -Path "$tempPath/node_modules/*" -Destination "$directory/node_modules" -Recurse
7477
}
7578
}
7679

0 commit comments

Comments
 (0)