@@ -3,30 +3,19 @@ import {
3
3
addTypeChecks , expandType , compareAST , code2ast2code
4
4
} from '@runtime-type-inspector/transpiler' ;
5
5
/**
6
- * Alternatively "import * as rti from ..." would also prevent "Unused external imports" warning...
7
- * or keeping log of every single call during RTI parsing.
8
- * @param {boolean } validateDivision
9
- */
10
- function getHeader ( validateDivision ) {
11
- let header = "import { assertType, youCanAddABreakpointHere" ;
12
- if ( validateDivision ) {
13
- header += ", validateDivision" ;
14
- }
15
- header += ", registerTypedef, registerClass } from '@runtime-type-inspector/runtime';\n" ;
16
- // Prevent tree-shaking in UMD build so we can always "add a breakpoint here".
17
- header += "export * from '@runtime-type-inspector/runtime';\n" ;
18
- return header ;
19
- }
20
- /**
21
- * @param {object } [options] - Optional options.
22
- * @param {boolean } [options.enable] - Enable or disable entire plugin. Defaults to true.
23
- * @param {boolean } [options.selftest] - Every once in a while Babel changes the AST, so we
6
+ * @typedef Options
7
+ * @property {boolean } [enable] - Enable or disable entire plugin. Defaults to true.
8
+ * @property {boolean } [selftest] - Every once in a while Babel changes the AST, so we
24
9
* self-test Stringifier class to ensure its functionanlity.
25
- * @param {string[] } [options. ignoredFiles] - Ignore certain files which operate in a different
10
+ * @property {string[] } [ignoredFiles] - Ignore certain files which operate in a different
26
11
* context, for example framework/parsers/draco-worker.js operates as WebWorker (without RTI).
12
+ * @property {boolean } [validateDivision] - Whether divisions are validated. Defaults to true.
13
+ */
14
+ /**
15
+ * @param {Options } [options] - Optional options.
27
16
* @returns {import('rollup').Plugin } The rollup plugin.
28
17
*/
29
- function runtimeTypeInspector ( { enable = true , selftest = false , ignoredFiles} = { } ) {
18
+ function runtimeTypeInspector ( { enable = true , selftest = false , ignoredFiles, validateDivision = true } = { } ) {
30
19
const filter = createFilter ( [
31
20
'**/*.js'
32
21
] , [ ] ) ;
@@ -46,8 +35,6 @@ function runtimeTypeInspector({enable = true, selftest = false, ignoredFiles} =
46
35
console . warn ( `AST is NOT equal` ) ;
47
36
}
48
37
}
49
- const validateDivision = true ;
50
- code = getHeader ( validateDivision ) + code ;
51
38
// todo expose options to rollup plugin
52
39
code = addTypeChecks ( code , {
53
40
validateDivision,
0 commit comments