Skip to content

Commit a003eae

Browse files
committed
Update chunks format
1 parent 14b4f14 commit a003eae

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

scripts/deploy/deploy.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ const uploadPathTypes = process.argv[4].split(',')
3939
runMain(async () => {
4040
const awsConfig = AWS_CONFIG[env]
4141
let cloudfrontPathsToInvalidate = []
42-
for (const { packageName, chunks } of packages) {
43-
const pathsToInvalidate = await uploadPackage(awsConfig, packageName, chunks)
42+
for (const { packageName } of packages) {
43+
const pathsToInvalidate = await uploadPackage(awsConfig, packageName)
4444
cloudfrontPathsToInvalidate.push(...pathsToInvalidate)
4545
}
4646
invalidateCloudfront(awsConfig, cloudfrontPathsToInvalidate)
@@ -55,6 +55,7 @@ async function uploadPackage(awsConfig, packageName) {
5555
if (!bundlePath.endsWith('.js')) {
5656
return
5757
}
58+
5859
const relativeBundlePath = bundlePath.replace(`${bundleFolder}/`, '')
5960
const uploadPath = await generateUploadPath(uploadPathType, relativeBundlePath, version)
6061

@@ -66,7 +67,7 @@ async function uploadPackage(awsConfig, packageName) {
6667
return cloudfrontPathsToInvalidate
6768
}
6869

69-
async function generateUploadPath(uploadPathType, chunkName, version) {
70+
async function generateUploadPath(uploadPathType, filePath, version) {
7071
let uploadPath
7172

7273
if (uploadPathType === 'pull-request') {
@@ -75,11 +76,11 @@ async function generateUploadPath(uploadPathType, chunkName, version) {
7576
console.log('No pull requests found for the branch')
7677
process.exit(0)
7778
}
78-
uploadPath = buildPullRequestUploadPath(chunkName, pr.number)
79+
uploadPath = buildPullRequestUploadPath(filePath, pr.number)
7980
} else if (uploadPathType === 'root') {
80-
uploadPath = buildRootUploadPath(chunkName, version)
81+
uploadPath = buildRootUploadPath(filePath, version)
8182
} else {
82-
uploadPath = buildDatacenterUploadPath(uploadPathType, chunkName, version)
83+
uploadPath = buildDatacenterUploadPath(uploadPathType, filePath, version)
8384
}
8485

8586
return uploadPath

scripts/deploy/lib/deploymentUtils.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const packages = [
2-
{ packageName: 'logs', chunks: ['datadog-logs'], service: 'browser-logs-sdk' },
3-
{ packageName: 'rum', chunks: ['datadog-rum', 'recorder.datadog-rum'], service: 'browser-rum-sdk' },
4-
{ packageName: 'rum-slim', chunks: ['datadog-rum-slim'], service: 'browser-rum-sdk' },
2+
{ packageName: 'logs', service: 'browser-logs-sdk' },
3+
{ packageName: 'rum', service: 'browser-rum-sdk' },
4+
{ packageName: 'rum-slim', service: 'browser-rum-sdk' },
55
]
66

77
// ex: datadog-rum-v4.js, chunks/recorder-8d8a8dfab6958424038f-datadog-rum-v4.js
@@ -12,16 +12,14 @@ const buildRootUploadPath = (filePath, version) => {
1212
return `${basePath}-${version}.${ext}`
1313
}
1414

15-
// ex: us1/v4/datadog-rum.js, eu1/v4/recorder.datadog-rum.js
16-
const buildDatacenterUploadPath = (datacenter, chunkName, version, extension = 'js') =>
17-
`${datacenter}/${version}/${chunkName}.${extension}`
15+
// ex: us1/v4/datadog-rum.js, eu1/v4/chunks/recorder-8d8a8dfab6958424038f-datadog-rum.js
16+
const buildDatacenterUploadPath = (datacenter, filePath, version) => `${datacenter}/${version}/${filePath}`
1817

19-
// ex: datadog-rum.js, recorder.datadog-rum.js
20-
const buildBundleFileName = (chunkName, extension = 'js') => `${chunkName}.${extension}`
18+
// ex: datadog-rum.js, chunks/recorder-8d8a8dfab6958424038f-datadog-rum.js
19+
const buildBundleFileName = (filePath) => `${filePath}`
2120

22-
// ex: pull-request/2781/datadog-rum.js, pull-request/2781/recorder.datadog-rum.js
23-
const buildPullRequestUploadPath = (chunkName, version, extension = 'js') =>
24-
`pull-request/${version}/${chunkName}.${extension}`
21+
// ex: pull-request/2781/datadog-rum.js, pull-request/2781/chunks/recorder-8d8a8dfab6958424038f-datadog-rum.js
22+
const buildPullRequestUploadPath = (filePath, version) => `pull-request/${version}/${filePath}`
2523

2624
// ex: packages/rum/bundle
2725
const buildBundleFolder = (packageName) => `packages/${packageName}/bundle`

webpack.base.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = ({ entry, mode, filename, types, keepBuildEnvVariables, plugins
1111
mode,
1212
output: {
1313
filename,
14+
chunkFilename: `chunks/[name]-[contenthash]-${filename}`,
1415
path: path.resolve('./bundle'),
1516
},
1617
target: ['web', 'es2018'],

0 commit comments

Comments
 (0)