@sentry/bundler-plugins 11.18.0 → 11.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/core/index.js +1 -2
- package/build/cjs/core/index.js.map +1 -1
- package/build/cjs/core/options-mapping.js.map +1 -1
- package/build/cjs/core/sentry/telemetry.js +1 -1
- package/build/cjs/core/sentry/telemetry.js.map +1 -1
- package/build/cjs/core/sourcemap-settings.js +26 -22
- package/build/cjs/core/sourcemap-settings.js.map +1 -1
- package/build/cjs/core/version.js +1 -1
- package/build/cjs/core/version.js.map +1 -1
- package/build/cjs/rewriter/arrays.js +25 -0
- package/build/cjs/rewriter/arrays.js.map +1 -0
- package/build/cjs/rewriter/ast.js +102 -0
- package/build/cjs/rewriter/ast.js.map +1 -0
- package/build/cjs/rewriter/class-extends.js +67 -0
- package/build/cjs/rewriter/class-extends.js.map +1 -0
- package/build/cjs/rewriter/exports.js +241 -0
- package/build/cjs/rewriter/exports.js.map +1 -0
- package/build/cjs/rewriter/imports.js +22 -0
- package/build/cjs/rewriter/imports.js.map +1 -0
- package/build/cjs/rewriter/index.js +45 -0
- package/build/cjs/rewriter/module-shape.js +120 -0
- package/build/cjs/rewriter/module-shape.js.map +1 -0
- package/build/cjs/rewriter/parse.js +64 -0
- package/build/cjs/rewriter/parse.js.map +1 -0
- package/build/cjs/rewriter/report.js +17 -0
- package/build/cjs/rewriter/report.js.map +1 -0
- package/build/cjs/rewriter/rewriter.js +68 -0
- package/build/cjs/rewriter/rewriter.js.map +1 -0
- package/build/cjs/vite/source-map-hooks.js +1 -1
- package/build/cjs/vite/source-map-hooks.js.map +1 -1
- package/build/esm/core/index.js +2 -2
- package/build/esm/core/index.js.map +1 -1
- package/build/esm/core/options-mapping.js.map +1 -1
- package/build/esm/core/sentry/telemetry.js +1 -1
- package/build/esm/core/sentry/telemetry.js.map +1 -1
- package/build/esm/core/sourcemap-settings.js +26 -21
- package/build/esm/core/sourcemap-settings.js.map +1 -1
- package/build/esm/core/version.js +1 -1
- package/build/esm/core/version.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/rewriter/arrays.js +25 -0
- package/build/esm/rewriter/arrays.js.map +1 -0
- package/build/esm/rewriter/ast.js +95 -0
- package/build/esm/rewriter/ast.js.map +1 -0
- package/build/esm/rewriter/class-extends.js +67 -0
- package/build/esm/rewriter/class-extends.js.map +1 -0
- package/build/esm/rewriter/exports.js +231 -0
- package/build/esm/rewriter/exports.js.map +1 -0
- package/build/esm/rewriter/imports.js +21 -0
- package/build/esm/rewriter/imports.js.map +1 -0
- package/build/esm/rewriter/index.js +11 -0
- package/build/esm/rewriter/module-shape.js +118 -0
- package/build/esm/rewriter/module-shape.js.map +1 -0
- package/build/esm/rewriter/parse.js +60 -0
- package/build/esm/rewriter/parse.js.map +1 -0
- package/build/esm/rewriter/report.js +16 -0
- package/build/esm/rewriter/report.js.map +1 -0
- package/build/esm/rewriter/rewriter.js +65 -0
- package/build/esm/rewriter/rewriter.js.map +1 -0
- package/build/esm/vite/source-map-hooks.js +2 -2
- package/build/esm/vite/source-map-hooks.js.map +1 -1
- package/build/types/core/index.d.ts +1 -1
- package/build/types/core/index.d.ts.map +1 -1
- package/build/types/core/options-mapping.d.ts +2 -2
- package/build/types/core/options-mapping.d.ts.map +1 -1
- package/build/types/core/sentry/telemetry.d.ts.map +1 -1
- package/build/types/core/sourcemap-settings.d.ts +8 -6
- package/build/types/core/sourcemap-settings.d.ts.map +1 -1
- package/build/types/core/types.d.ts +14 -11
- package/build/types/core/types.d.ts.map +1 -1
- package/build/types/core/version.d.ts +1 -1
- package/build/types/rewriter/arrays.d.ts +12 -0
- package/build/types/rewriter/arrays.d.ts.map +1 -0
- package/build/types/rewriter/ast.d.ts +120 -0
- package/build/types/rewriter/ast.d.ts.map +1 -0
- package/build/types/rewriter/class-extends.d.ts +16 -0
- package/build/types/rewriter/class-extends.d.ts.map +1 -0
- package/build/types/rewriter/exports.d.ts +88 -0
- package/build/types/rewriter/exports.d.ts.map +1 -0
- package/build/types/rewriter/imports.d.ts +7 -0
- package/build/types/rewriter/imports.d.ts.map +1 -0
- package/build/types/rewriter/index.d.ts +10 -0
- package/build/types/rewriter/index.d.ts.map +1 -0
- package/build/types/rewriter/module-shape.d.ts +47 -0
- package/build/types/rewriter/module-shape.d.ts.map +1 -0
- package/build/types/rewriter/parse.d.ts +27 -0
- package/build/types/rewriter/parse.d.ts.map +1 -0
- package/build/types/rewriter/report.d.ts +12 -0
- package/build/types/rewriter/report.d.ts.map +1 -0
- package/build/types/rewriter/rewriter.d.ts +64 -0
- package/build/types/rewriter/rewriter.d.ts.map +1 -0
- package/build/types/vite/source-map-hooks.d.ts.map +1 -1
- package/package.json +9 -4
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { BaseNode, ClassDeclarationNode, ExportDefaultNode, ExportNamedNode, ExportSpecifierNode, ProgramBody } from './ast';
|
|
2
|
+
import type { RewriteState } from './rewriter';
|
|
3
|
+
/** Builds the expression that wraps `target`, e.g. `target => \`wrap(${target})\``. */
|
|
4
|
+
export type WrapExpression = (target: string) => string;
|
|
5
|
+
/**
|
|
6
|
+
* Handles one export specifier of a statement passed to {@link wrapSpecifierExports}.
|
|
7
|
+
* Returns the `Wrapped as Exported` pair to emit in its place, or `undefined`
|
|
8
|
+
* to keep the specifier as written. Statements the pair depends on go onto
|
|
9
|
+
* `prelude`, which is emitted before the rebuilt export.
|
|
10
|
+
*/
|
|
11
|
+
export type SpecifierWrapper = (specifier: ExportSpecifierNode, sourceLiteral: string | undefined, prelude: string[]) => string | undefined;
|
|
12
|
+
/** Top-level class declarations, exported or not, by name. */
|
|
13
|
+
export declare function collectTopLevelClasses(ast: ProgramBody): Map<string, ClassDeclarationNode>;
|
|
14
|
+
/** Top-level value binding name → the statement that declares it. */
|
|
15
|
+
export declare function collectDeclaringStatements(ast: ProgramBody): Map<string, BaseNode>;
|
|
16
|
+
/**
|
|
17
|
+
* Top-level bindings already assigned the result of one of `wrapperNames`
|
|
18
|
+
* (`const X = wrap(...)`), so exporting one must not wrap it a second time.
|
|
19
|
+
*/
|
|
20
|
+
export declare function collectManuallyWrappedLocals(ast: ProgramBody, wrapperNames: readonly string[]): Set<string>;
|
|
21
|
+
/** The value export statements (`export const`, `export { }`) that export `name`. */
|
|
22
|
+
export declare function findNamedExports(ast: ProgramBody, name: string): ExportNamedNode[];
|
|
23
|
+
/**
|
|
24
|
+
* Wrap a binding declared in this module and return the binding that holds the wrapper.
|
|
25
|
+
*
|
|
26
|
+
* The declaration is left exactly as written, so a class or function keeps its
|
|
27
|
+
* `Function.prototype.name`. Only the *export* has to become the wrapper, so the wrapper gets its
|
|
28
|
+
* own binding and the export is aliased to it.
|
|
29
|
+
*/
|
|
30
|
+
export declare function wrapLocalBinding(state: RewriteState, localName: string, declaringNode: BaseNode, wrap: WrapExpression): string;
|
|
31
|
+
/**
|
|
32
|
+
* Wrap `localName` where an inline export declares it (`export class X {}`,
|
|
33
|
+
* `export const x = ...`, `export function x() {}`). The `export` keyword is
|
|
34
|
+
* replaced by an export clause that aliases the name to the wrapper. Other
|
|
35
|
+
* names the same declaration exports are exported again, through their
|
|
36
|
+
* wrapper when a later call wraps them too.
|
|
37
|
+
*
|
|
38
|
+
* @returns whether the declaration exports `localName`
|
|
39
|
+
*/
|
|
40
|
+
export declare function wrapInlineExport(state: RewriteState, exportNode: ExportNamedNode, localName: string, wrap: WrapExpression): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Wrap the specifiers of an `export { ... }` statement that `wrapSpecifier` picks.
|
|
43
|
+
*
|
|
44
|
+
* Each such specifier is re-pointed at a binding holding the wrapper, which means rebuilding the
|
|
45
|
+
* statement; the other specifiers are carried over verbatim. A binding that lives in **another**
|
|
46
|
+
* module is first bound under a private name (see {@link wrapForeignExport}), since an import
|
|
47
|
+
* binding cannot be reassigned and the `from` form has no local binding at all.
|
|
48
|
+
*/
|
|
49
|
+
export declare function wrapSpecifierExports(state: RewriteState, node: ExportNamedNode, wrapSpecifier: SpecifierWrapper): void;
|
|
50
|
+
/**
|
|
51
|
+
* Wrap a binding that comes from another module: imported and re-exported
|
|
52
|
+
* (`sourceLiteral` undefined), or re-exported directly (`export { x } from`).
|
|
53
|
+
* Pushes the statements that bind the wrapper onto `prelude` and returns the
|
|
54
|
+
* pair to export.
|
|
55
|
+
*/
|
|
56
|
+
export declare function wrapForeignExport(state: RewriteState, localName: string, exportedAs: string, sourceLiteral: string | undefined, prelude: string[], wrap: WrapExpression): string;
|
|
57
|
+
/**
|
|
58
|
+
* Wrap `export default <declaration or expression>`.
|
|
59
|
+
*
|
|
60
|
+
* `export default Foo`, where `Foo` already has a wrapper binding (a class
|
|
61
|
+
* also exported by name), is re-pointed at that binding instead of wrapping
|
|
62
|
+
* twice.
|
|
63
|
+
*/
|
|
64
|
+
export declare function wrapDefaultExport(state: RewriteState, node: ExportDefaultNode, wrap: WrapExpression): void;
|
|
65
|
+
/**
|
|
66
|
+
* `export { handler as default }`, the form bundlers emit for a default export. The export is set
|
|
67
|
+
* in two steps. Right after `handler` is declared, it is bound to `handler` as-is, so a circular
|
|
68
|
+
* import that reads it during module evaluation gets the handler, as before the transform. At the
|
|
69
|
+
* end of the module, it is rebound to the wrapper, so a handler assigned or given methods later is
|
|
70
|
+
* wrapped as it ends up. The binding is a `var`: a read before `handler` is declared gets
|
|
71
|
+
* `undefined`, as it would from the bundler's own `var`, where a `const` would throw and stop the
|
|
72
|
+
* Worker from starting.
|
|
73
|
+
*
|
|
74
|
+
* @returns the pair to export in place of the specifier
|
|
75
|
+
*/
|
|
76
|
+
export declare function wrapDefaultSpecifier(state: RewriteState, localName: string, declaringStatement: BaseNode | undefined, wrap: WrapExpression): string;
|
|
77
|
+
/**
|
|
78
|
+
* `export { default } from './handler'` and `export { x as default } from './handler'`.
|
|
79
|
+
*
|
|
80
|
+
* The original re-export is a live binding to the handler module's export, but the wrapper is not
|
|
81
|
+
* set until this module's body runs. A circular import that reads the default export before then
|
|
82
|
+
* gets `undefined` instead of the handler. The binding is a `var` so that the read does not throw,
|
|
83
|
+
* as a `const` would, and stop the Worker from starting. See `wrapDefaultSpecifier`.
|
|
84
|
+
*
|
|
85
|
+
* @returns the pair to export in place of the specifier
|
|
86
|
+
*/
|
|
87
|
+
export declare function wrapDefaultReexport(state: RewriteState, localName: string, sourceLiteral: string, prelude: string[], wrap: WrapExpression): string;
|
|
88
|
+
//# sourceMappingURL=exports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../src/rewriter/exports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EAGnB,WAAW,EAEZ,MAAM,OAAO,CAAC;AASf,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,uFAAuF;AACvF,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;AAExD;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAC7B,SAAS,EAAE,mBAAmB,EAC9B,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,OAAO,EAAE,MAAM,EAAE,KACd,MAAM,GAAG,SAAS,CAAC;AAKxB,8DAA8D;AAC9D,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAS1F;AAED,qEAAqE;AACrE,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAYlF;AASD;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAgB3G;AAED,qFAAqF;AACrF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE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 +1,7 @@
|
|
|
1
|
+
import type { ProgramBody } from './ast';
|
|
2
|
+
import type { RewriteState } from './rewriter';
|
|
3
|
+
/** Whether the module already binds `name` to the export of the same name from `module`. */
|
|
4
|
+
export declare function hasImport(ast: ProgramBody, module: string, name: string): boolean;
|
|
5
|
+
/** Adds an import statement after the hashbang and directives, once per module. */
|
|
6
|
+
export declare function addImport(state: RewriteState, ast: ProgramBody, statement: string): void;
|
|
7
|
+
//# sourceMappingURL=imports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imports.d.ts","sourceRoot":"","sources":["../../../src/rewriter/imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,WAAW,EAAE,MAAM,OAAO,CAAC;AAEhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,4FAA4F;AAC5F,wBAAgB,SAAS,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAajF;AAED,mFAAmF;AACnF,wBAAgB,SAAS,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAMxF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './ast';
|
|
2
|
+
export * from './arrays';
|
|
3
|
+
export * from './class-extends';
|
|
4
|
+
export * from './exports';
|
|
5
|
+
export * from './imports';
|
|
6
|
+
export * from './module-shape';
|
|
7
|
+
export * from './parse';
|
|
8
|
+
export * from './report';
|
|
9
|
+
export * from './rewriter';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rewriter/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ProgramBody } from './ast';
|
|
2
|
+
/** Binding name used for a module's default export. */
|
|
3
|
+
export declare const DEFAULT_EXPORT = "default";
|
|
4
|
+
/** A resolved superclass reference: a bare identifier or a `ns.Member` expression. */
|
|
5
|
+
export type SuperRef = {
|
|
6
|
+
kind: 'identifier';
|
|
7
|
+
name: string;
|
|
8
|
+
} | {
|
|
9
|
+
kind: 'member';
|
|
10
|
+
object: string;
|
|
11
|
+
property: string;
|
|
12
|
+
};
|
|
13
|
+
/** The declarations of a single module that binding resolution needs. */
|
|
14
|
+
export interface ModuleShape {
|
|
15
|
+
/** Top-level class names → their superclass reference (absent when the class has no `extends`). */
|
|
16
|
+
classes: Map<string, SuperRef | undefined>;
|
|
17
|
+
/** Local binding name → the import it came from (`imported` is `default` for a default import). */
|
|
18
|
+
imports: Map<string, {
|
|
19
|
+
source: string;
|
|
20
|
+
imported: string;
|
|
21
|
+
}>;
|
|
22
|
+
/** Local binding name → module specifier, for `import * as ns from '...'`. */
|
|
23
|
+
namespaces: Map<string, string>;
|
|
24
|
+
/** Exported name → the re-export it came from, for `export { x as y } from '...'`. */
|
|
25
|
+
reexports: Map<string, {
|
|
26
|
+
source: string;
|
|
27
|
+
imported: string;
|
|
28
|
+
}>;
|
|
29
|
+
/** Exported name → local binding name, for `export { x as y }` without a source. */
|
|
30
|
+
localExports: Map<string, string>;
|
|
31
|
+
/** Module specifiers of bare `export * from '...'` declarations. */
|
|
32
|
+
starExports: string[];
|
|
33
|
+
/** `export default <Identifier>` — the local name it refers to. */
|
|
34
|
+
defaultExportName?: string;
|
|
35
|
+
/** True when the module's default export is a class declaration/expression. */
|
|
36
|
+
defaultExportIsClass?: boolean;
|
|
37
|
+
/** Superclass of an anonymous `export default class extends X`. */
|
|
38
|
+
defaultExportSuper?: SuperRef;
|
|
39
|
+
}
|
|
40
|
+
/** Collect the shape of a module from its parsed AST. */
|
|
41
|
+
export declare function shapeFromAst(ast: ProgramBody): ModuleShape;
|
|
42
|
+
/**
|
|
43
|
+
* Extract the module shape from unprocessed source, such as a sibling module
|
|
44
|
+
* read off disk. Returns `undefined` when the source does not parse.
|
|
45
|
+
*/
|
|
46
|
+
export declare function shapeFromSource(code: string, id: string): ModuleShape | undefined;
|
|
47
|
+
//# sourceMappingURL=module-shape.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-shape.d.ts","sourceRoot":"","sources":["../../../src/rewriter/module-shape.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EASV,WAAW,EACZ,MAAM,OAAO,CAAC;AAIf,uDAAuD;AACvD,eAAO,MAAM,cAAc,YAAY,CAAC;AAExC,sFAAsF;AACtF,MAAM,MAAM,QAAQ,GAAG;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnH,yEAAyE;AACzE,MAAM,WAAW,WAAW;IAC1B,mGAAmG;IACnG,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,CAAC,CAAC;IAC3C,mGAAmG;IACnG,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC3D,8EAA8E;IAC9E,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,sFAAsF;IACtF,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7D,oFAAoF;IACpF,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,oEAAoE;IACpE,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,mEAAmE;IACnE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,+EAA+E;IAC/E,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mEAAmE;IACnE,kBAAkB,CAAC,EAAE,QAAQ,CAAC;CAC/B;AAaD,yDAAyD;AACzD,wBAAgB,YAAY,CAAC,GAAG,EAAE,WAAW,GAAG,WAAW,CAqC1D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAYjF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ProgramBody } from './ast';
|
|
2
|
+
export type ModuleLang = 'js' | 'jsx' | 'ts' | 'tsx';
|
|
3
|
+
/** Parses a module into an ESTree program. Throws when the code does not parse. */
|
|
4
|
+
export type ModuleParser = (code: string, id: string) => ProgramBody;
|
|
5
|
+
/** The part of a bundler's plugin context that can parse code. */
|
|
6
|
+
export interface ParserContext {
|
|
7
|
+
meta?: {
|
|
8
|
+
rolldownVersion?: string;
|
|
9
|
+
};
|
|
10
|
+
parse?(input: string, options?: object | null): unknown;
|
|
11
|
+
}
|
|
12
|
+
/** Resolves once `oxc-parser` has loaded or failed to load, with whether it is available. */
|
|
13
|
+
export declare function loadParser(): Promise<boolean>;
|
|
14
|
+
export declare function isParserLoading(): boolean;
|
|
15
|
+
/** The source dialect a module id names by its extension. */
|
|
16
|
+
export declare function langFromId(id: string): ModuleLang;
|
|
17
|
+
/**
|
|
18
|
+
* The default {@link ModuleParser}, over `oxc-parser`. Throws when `oxc-parser`
|
|
19
|
+
* has not loaded; see {@link loadParser}.
|
|
20
|
+
*/
|
|
21
|
+
export declare function parseModule(code: string, id: string, lang?: ModuleLang): ProgramBody;
|
|
22
|
+
/**
|
|
23
|
+
* A parser over Rolldown's own `this.parse`, which reads TypeScript when told
|
|
24
|
+
* the dialect. Rollup's `this.parse` cannot, so it is not used.
|
|
25
|
+
*/
|
|
26
|
+
export declare function bundlerParser(context: ParserContext | undefined): ModuleParser | undefined;
|
|
27
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../src/rewriter/parse.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEzC,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,CAAC;AAErD,mFAAmF;AACnF,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,WAAW,CAAC;AAErE,kEAAkE;AAClE,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE;QAAE,eAAe,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACpC,KAAK,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC;CACzD;AAuBD,6FAA6F;AAC7F,wBAAgB,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC,CAE7C;AAED,wBAAgB,eAAe,IAAI,OAAO,CAEzC;AAED,6DAA6D;AAC7D,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,CAKjD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,GAAE,UAA2B,GAAG,WAAW,CAgBpG;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,CAG1F"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** What a rewrite did with the sites it found, by site label. */
|
|
2
|
+
export interface RewriteReport {
|
|
3
|
+
wrapped: string[];
|
|
4
|
+
/** Sites the rewrite could not wrap, for the user to wrap by hand. */
|
|
5
|
+
skipped: string[];
|
|
6
|
+
/** Sites the user already wrapped. */
|
|
7
|
+
alreadyWrapped: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare function createReport(): RewriteReport;
|
|
10
|
+
/** The warning for the skipped sites of a module, or `undefined` when none were skipped. */
|
|
11
|
+
export declare function formatReport(report: RewriteReport, id: string): string | undefined;
|
|
12
|
+
//# sourceMappingURL=report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../src/rewriter/report.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,sEAAsE;IACtE,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,sCAAsC;IACtC,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,wBAAgB,YAAY,IAAI,aAAa,CAE5C;AAED,4FAA4F;AAC5F,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGlF"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import MagicString, { type SourceMap } from 'magic-string';
|
|
2
|
+
import type { ProgramBody } from './ast';
|
|
3
|
+
import { type ModuleParser, type ParserContext } from './parse';
|
|
4
|
+
import { type RewriteReport } from './report';
|
|
5
|
+
/** The edits a rewrite makes to one module, shared by every rule that runs on it. */
|
|
6
|
+
export interface RewriteState {
|
|
7
|
+
/** Positions are always relative to the original source. */
|
|
8
|
+
ms: MagicString;
|
|
9
|
+
/** Set once the rewritten code references a binding the caller must import. */
|
|
10
|
+
needsImport: boolean;
|
|
11
|
+
/** Local binding name → the binding that holds its wrapper. */
|
|
12
|
+
wrappedLocals: Map<string, string>;
|
|
13
|
+
/** Import statements already added to this module. */
|
|
14
|
+
imports: Set<string>;
|
|
15
|
+
report: RewriteReport;
|
|
16
|
+
}
|
|
17
|
+
export declare function createRewriteState(code: string): RewriteState;
|
|
18
|
+
/** Which modules a rule runs on. Every given condition must hold. */
|
|
19
|
+
export interface RuleInclude {
|
|
20
|
+
/** Tested against the full module id. */
|
|
21
|
+
id?: RegExp;
|
|
22
|
+
/** Tested against the last path segment of the module id. */
|
|
23
|
+
basename?: RegExp;
|
|
24
|
+
/** Substrings the source must contain, checked before parsing. */
|
|
25
|
+
contains?: string[];
|
|
26
|
+
}
|
|
27
|
+
export interface RuleContext {
|
|
28
|
+
ast: ProgramBody;
|
|
29
|
+
code: string;
|
|
30
|
+
id: string;
|
|
31
|
+
state: RewriteState;
|
|
32
|
+
}
|
|
33
|
+
export interface RewriteRule {
|
|
34
|
+
name: string;
|
|
35
|
+
include: RuleInclude;
|
|
36
|
+
apply(ctx: RuleContext): void | Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
export interface RewriterOptions {
|
|
39
|
+
/**
|
|
40
|
+
* Defaults to Rolldown's `this.parse` when the transform gets a Rolldown
|
|
41
|
+
* plugin context, and to {@link parseModule} otherwise.
|
|
42
|
+
*/
|
|
43
|
+
parse?: ModuleParser;
|
|
44
|
+
/** Receives the warning for sites a rule could not wrap. */
|
|
45
|
+
logger?: {
|
|
46
|
+
warn(message: string): void;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export interface RewriteOutput {
|
|
50
|
+
code: string;
|
|
51
|
+
map: SourceMap;
|
|
52
|
+
}
|
|
53
|
+
export interface CallSiteRewriter {
|
|
54
|
+
/**
|
|
55
|
+
* Runs every matching rule on one module. Returns `null` when nothing
|
|
56
|
+
* changed. The result is a promise only while `oxc-parser` is still
|
|
57
|
+
* loading, or when a rule's `apply` returns one.
|
|
58
|
+
*
|
|
59
|
+
* @param context the bundler's plugin context, for its parser
|
|
60
|
+
*/
|
|
61
|
+
transform(code: string, id: string, context?: ParserContext): RewriteOutput | null | Promise<RewriteOutput | null>;
|
|
62
|
+
}
|
|
63
|
+
export declare function createCallSiteRewriter(rules: RewriteRule[], options?: RewriterOptions): CallSiteRewriter;
|
|
64
|
+
//# sourceMappingURL=rewriter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rewriter.d.ts","sourceRoot":"","sources":["../../../src/rewriter/rewriter.ts"],"names":[],"mappings":"AACA,OAAO,WAAW,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAIL,KAAK,YAAY,EAEjB,KAAK,aAAa,EACnB,MAAM,SAAS,CAAC;AACjB,OAAO,EAA8B,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAE1E,qFAAqF;AACrF,MAAM,WAAW,YAAY;IAC3B,4DAA4D;IAC5D,EAAE,EAAE,WAAW,CAAC;IAChB,+EAA+E;IAC/E,WAAW,EAAE,OAAO,CAAC;IACrB,+DAA+D;IAC/D,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,sDAAsD;IACtD,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACrB,MAAM,EAAE,aAAa,CAAC;CACvB;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAQ7D;AAED,qEAAqE;AACrE,MAAM,WAAW,WAAW;IAC1B,yCAAyC;IACzC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EA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K,IAAI,CAAC;IACrD,aAAa,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;CACzD,CAAC;AAiCF;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,wBAAwB,EAAE,wBAAwB,EAClD,iBAAiB,EAAE,iBAAiB,GACnC,kBAAkB,CA0FpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/bundler-plugins",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.20.0",
|
|
4
4
|
"description": "Sentry Bundler Plugins",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -62,6 +62,11 @@
|
|
|
62
62
|
"import": "./build/esm/babel-plugin/index.js",
|
|
63
63
|
"require": "./build/cjs/babel-plugin/index.js"
|
|
64
64
|
},
|
|
65
|
+
"./rewriter": {
|
|
66
|
+
"types": "./build/types/rewriter/index.d.ts",
|
|
67
|
+
"import": "./build/esm/rewriter/index.js",
|
|
68
|
+
"require": "./build/cjs/rewriter/index.js"
|
|
69
|
+
},
|
|
65
70
|
"./sentry-release-injection-file": {
|
|
66
71
|
"import": "./sentry-release-injection-file.js",
|
|
67
72
|
"require": "./sentry-release-injection-file.js"
|
|
@@ -91,7 +96,7 @@
|
|
|
91
96
|
}
|
|
92
97
|
},
|
|
93
98
|
"dependencies": {
|
|
94
|
-
"@sentry/core": "11.
|
|
99
|
+
"@sentry/core": "11.20.0",
|
|
95
100
|
"dotenv": "^17.4.2",
|
|
96
101
|
"glob": "^14.0.3",
|
|
97
102
|
"magic-string": "~0.30.8 || ^1.0.0",
|
|
@@ -114,8 +119,8 @@
|
|
|
114
119
|
"@babel/core": "^7.18.5",
|
|
115
120
|
"@babel/parser": "^8.0.10",
|
|
116
121
|
"@babel/preset-react": "^7.23.3",
|
|
117
|
-
"@sentry-internal/rollup-utils": "11.
|
|
118
|
-
"@sentry-internal/test-utils": "11.
|
|
122
|
+
"@sentry-internal/rollup-utils": "11.20.0",
|
|
123
|
+
"@sentry-internal/test-utils": "11.20.0",
|
|
119
124
|
"@types/babel__core": "^7.20.5",
|
|
120
125
|
"@types/node": "^20.19.0",
|
|
121
126
|
"rolldown": "^1.0.0",
|