Skip to content

Commit

Permalink
fix(vite-plugin-angular): use babel to make transform results compati…
Browse files Browse the repository at this point in the history
…ble with Webkit

Angular's compilation results use static blocks by default.
These static blocks are not supported by Safari or other webkit based browsers.
https://caniuse.com/mdn-javascript_classes_static_initialization_blocks
We need to use babel transformations to make the output compatible with iOS if we
want to support them.

Closes #202
  • Loading branch information
goetzrobin committed Jan 30, 2023
1 parent 4709629 commit bb9d5fb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/vite-plugin-angular/src/lib/angular-vite-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface PluginOptions {
*/
tsTransformers?: ts.CustomTransformers;
};
supportedBrowsers?: string[];
}

interface EmitFileResult {
Expand Down Expand Up @@ -63,6 +64,7 @@ export function angular(options?: PluginOptions): Plugin[] {
options?.advanced?.tsTransformers?.afterDeclarations ?? [],
},
},
supportedBrowsers: options?.supportedBrowsers ?? ['iOS <=15'],
};

// The file emitter created during `onStart` that will be used during the build in `onLoad` callbacks for TS files
Expand Down Expand Up @@ -273,6 +275,7 @@ export function angular(options?: PluginOptions): Plugin[] {
[
angularApplicationPreset,
{
supportedBrowsers: pluginOptions.supportedBrowsers,
forceAsyncTransformation,
optimize: isProd && {},
},
Expand Down

0 comments on commit bb9d5fb

Please sign in to comment.