Skip to content

Commit 2eee0a9

Browse files
authored
chore: exclude test and config files from minification (#36038)
### Issue # (if applicable) When running `yarn package` inside `aws-cdk-lib`, a pre package command is executed to minify all source files. This command unintentionally minifies checked-in files that should not be minified, as demonstrated by the diff that is present afterwards. <img width="514" height="204" alt="image" src="https://github.com/user-attachments/assets/67fc4c24-2345-4859-85e4-f74475bfa512" /> ### Reason for this change Fix the above bug. ### Description of changes Adjusted the `find` command to exclude files we don't want to minify. ### Describe any new or updated permissions being added n/a ### Description of how you validated changes Now no unintentionally minified files are showing up in the diff. I have compared the outputs of the previous and updated `find` commands: ``` < ./aws-appsync/test/integ-assets/appsync-js-pipeline.js < ./aws-appsync/test/integ-assets/appsync-js-resolver.js < ./aws-appsync/test/integ-assets/js-resolver-assertion/index.js < ./aws-appsync/test/verify/eventapi-lambda-direct/handler.js < ./aws-appsync/test/verify/eventapi-lambda-ds/handler.js < ./aws-appsync/test/verify/iam-query/iam-query.js < ./aws-appsync/test/verify/lambda-tutorial/lambda-tutorial.js 418d410 < ./aws-cloudfront/test/function-code.js 1110d1101 < ./aws-iam/test/custom-resource/index.js 1938,1940d1928 < ./aws-synthetics/test/canaries/canary.js < ./aws-synthetics/test/canaries/playwright/canary.js < ./aws-synthetics/test/canaries/puppeteer/canary.js 2137d2124 < ./core/test/custom-resource-provider/mock-provider/index.js 2500d2486 < ./jest.config.js ``` As we can see, only the files we wanted to exclude are not present in the list anymore. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 35f8e46 commit 2eee0a9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/aws-cdk-lib/scripts/minify-sources.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
scriptdir=$(cd $(dirname $0) && pwd)
1717
cd ${scriptdir}/..
1818

19-
find . -name '*.js' ! -name '.eslintrc.js' ! -path '*node_modules*' | xargs npx esbuild \
19+
find . -name '*.js' ! -name '.eslintrc.js' ! -name 'jest.config.js' ! -path '*node_modules*' ! -path '**/test/**' | xargs npx esbuild \
2020
--platform=node \
2121
--format=cjs \
2222
--minify-whitespace \

0 commit comments

Comments
 (0)