-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: ♻️ refactor plugin-app-duration to typescript es module
- Loading branch information
1 parent
483e30a
commit c95a023
Showing
6 changed files
with
56 additions
and
6 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
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,25 @@ | ||
import createRollupConfig from '../../.rollup/index.mjs' | ||
|
||
export default createRollupConfig({ | ||
input: 'src/app-duration.ts', | ||
output: [ | ||
{ | ||
dir: `dist`, | ||
entryFileNames: '[name].js', | ||
format: 'cjs', | ||
preserveModules: true, | ||
generatedCode: { | ||
preset: 'es2015', | ||
} | ||
}, | ||
{ | ||
dir: `dist`, | ||
entryFileNames: '[name].mjs', | ||
format: 'esm', | ||
preserveModules: true, | ||
generatedCode: { | ||
preset: 'es2015', | ||
} | ||
} | ||
] | ||
}) |
9 changes: 7 additions & 2 deletions
9
packages/plugin-app-duration/app.js → ...s/plugin-app-duration/src/app-duration.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
import { Plugin } from 'packages/core/types' | ||
|
||
let appStart = new Date() | ||
const reset = () => { appStart = new Date() } | ||
|
||
module.exports = { | ||
const plugin: Plugin = { | ||
name: 'appDuration', | ||
load: client => { | ||
client.addOnError(event => { | ||
const now = new Date() | ||
|
||
event.app.duration = now - appStart | ||
event.app.duration = Number(now) - Number(appStart) | ||
// @ts-expect-error second argument is private API | ||
}, true) | ||
|
||
return { reset } | ||
} | ||
} | ||
|
||
export default plugin |
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,8 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": ["src/**/*.ts"], | ||
"compilerOptions": { | ||
"target": "ES2020" | ||
} | ||
} | ||
|
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