Skip to content

Commit

Permalink
remove ts declarations from CDN files
Browse files Browse the repository at this point in the history
  • Loading branch information
kochis committed Jun 17, 2023
1 parent 01da5e7 commit 53e2480
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/radar-pre-release-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ jobs:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-east-1'
SOURCE_DIR: 'dist/'
SOURCE_DIR: 'cdn/'
DEST_DIR: ${{ github.ref_name }} # the release tag
4 changes: 2 additions & 2 deletions .github/workflows/radar-release-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ jobs:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-east-1'
SOURCE_DIR: 'dist/'
SOURCE_DIR: 'cdn/'
DEST_DIR: ${{ github.ref_name }} # release tag
- uses: jakejarvis/s3-sync-action@master
env:
AWS_S3_BUCKET: js.radar.com
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-east-1'
SOURCE_DIR: 'dist/'
SOURCE_DIR: 'cdn/'
DEST_DIR: ${{ env.MAJOR_VERSION }} # release latest major version
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ node_modules/
npm-debug.log
*.framework
dist/
cdn/
coverage/
.nyc_output/
2 changes: 1 addition & 1 deletion demo/server.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const params = {
port: 9001,
host: "0.0.0.0",
root: "./demo", // Set root directory that's being served. Defaults to cwd.
mount: [['/dist', path.join(__dirname, '../dist')]], // server dist files under "/dist" path
mount: [['/dist', path.join(__dirname, '../cdn')]], // server dist files under "/dist" path
logLevel: 2, // 0 = errors only, 1 = some, 2 = lots
};

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "radar-sdk-js",
"version": "4.0.0-beta.4",
"version": "4.0.0-beta.5",
"description": "",
"type": "module",
"module": "dist/radar.js",
Expand Down
25 changes: 22 additions & 3 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@ import typescript from 'rollup-plugin-typescript2';
import json from '@rollup/plugin-json';
import terser from '@rollup/plugin-terser';

// remove typescript declarations from file in the CDN output folder
// (only keep the output file specified in the rollup config)
const onlyEmitFile = (options = {}) => ({
name: 'only-emit-file',

generateBundle(outputOptions, bundle) {
const outputFile = outputOptions.file;
const outputFileName = outputFile.split('/').pop();

for (const fileName in bundle) {
// remove file if doesn't match "file" in config
if (fileName !== outputFileName) {
delete bundle[fileName];
}
}
}
});

export default {
input: 'src/index.ts',
output: [
Expand All @@ -10,15 +28,16 @@ export default {
format: 'esm',
},
{
file: 'dist/radar.iife.js',
file: 'cdn/radar.js',
format: 'iife',
name: 'Radar',
plugins: [onlyEmitFile()],
},
{
file: 'dist/radar.iife.min.js',
file: 'cdn/radar.min.js',
format: 'iife',
name: 'Radar',
plugins: [terser()],
plugins: [terser(), onlyEmitFile()],
},
],
plugins: [
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default '4.0.0-beta.4';
export default '4.0.0-beta.5';

0 comments on commit 53e2480

Please sign in to comment.