-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use nft for bundling * Generate third-party license file on publish
- Loading branch information
Showing
12 changed files
with
409 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
* | ||
|
||
!package.json | ||
!yarn.lock | ||
!tsconfig.json | ||
!lib/package.json | ||
!scripts/* | ||
!lib/*.json | ||
!lib/**/*.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
dist | ||
dist.zip | ||
|
||
# Temporary license files | ||
third-party-licenses.txt | ||
LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "./dist" | ||
}, | ||
"include": ["./**/*"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Creates a bundled zip file with all dependencies for AWS Lambda | ||
*/ | ||
|
||
const path = require('path'); | ||
const fs = require('fs'); | ||
const { nodeFileTrace } = require('@vercel/nft'); | ||
const glob = require('glob'); | ||
const archiver = require('archiver'); | ||
|
||
const workspaceRoot = path.resolve(__dirname, '..'); | ||
const buildDir = path.resolve(workspaceRoot, 'lib/dist'); | ||
|
||
async function main() { | ||
// Get all files from build dir | ||
const buildFiles = glob.sync('**/*.js', { cwd: buildDir, absolute: true }); | ||
|
||
console.log('buildFiles', buildFiles); | ||
|
||
const { fileList } = await nodeFileTrace(buildFiles, { | ||
base: workspaceRoot, | ||
processCwd: process.cwd(), | ||
// aws-sdk is already provided in Lambda images | ||
ignore: ['**/aws-sdk/**/*'], | ||
}); | ||
|
||
// Create zip file | ||
await new Promise((resolve, reject) => { | ||
const outputFile = fs.createWriteStream( | ||
path.resolve(workspaceRoot, 'lib/dist.zip') | ||
); | ||
|
||
outputFile.on('close', () => resolve()); | ||
outputFile.on('error', (error) => reject(error)); | ||
|
||
const archive = archiver('zip', { | ||
zlib: { level: 5 }, // Optimal compression | ||
}); | ||
archive.pipe(outputFile); | ||
|
||
for (const file of fileList) { | ||
// Remove lib/ and lib/dist/ prefix | ||
const fileName = file.replace(/^lib\/(dist\/)?/, ''); | ||
|
||
archive.append(fs.createReadStream(path.join(workspaceRoot, file)), { | ||
name: fileName, | ||
mode: 0o666, | ||
}); | ||
} | ||
archive.finalize(); | ||
}); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.