Skip to content

Library design is incompatible with Angular's build system #10465

@joukevandermaas

Description

@joukevandermaas

I am struggling to see how to ever integrate this library with Angular, because Angular's build system (based on esbuild) does not allow for arbitrary build steps like Babel.

If it is your goal to eventually integrate with Angular I think this deserves some consideration; at the moment it seems not really possible to use it even if you're willing to write your own signal integration.

Details

I installed warp-drive into my angular 21 app:

pnpm add -E @warp-drive/core@latest @warp-drive/json-api@latest

Then I created a little reactivity wrapper to use angular signals

angular impl
import { computed, signal, WritableSignal } from '@angular/core';
import { type HooksOptions, setupSignals, type SignalHooks } from '@warp-drive/core/configure';

/* eslint-disable @typescript-eslint/no-unused-vars */
export function buildSignalConfig(_options: HooksOptions): SignalHooks<WritableSignal<unknown>> {
  return {
    createSignal: (obj: object, key: string | symbol) => signal(null),
    consumeSignal: (value: WritableSignal<unknown>) => void value(),
    notifySignal: (value: WritableSignal<unknown>) => value.set(null),
    createMemo: <F>(object: object, key: string | symbol, fn: () => F): (() => F) => {
      const memo = computed<F>(fn);
      return () => memo();
    },
    willSyncFlushWatchers: () => false,
  };
}
/* eslint-enable @typescript-eslint/no-unused-vars */

setupSignals(buildSignalConfig);


However it never even gets to that point, because the app never starts. The first import already fails with this error:

Uncaught Error: this method is really implemented at compile time via a babel plugin. If you're seeing this exception, something went wrong
    Oops index.js:72
    getGlobalConfig4 index.js:56
    <anonymous> -private.js:17
index.js:72:9
    Oops index.js:72
    getGlobalConfig4 index.js:56
    <anonymous> -private.js:17

The instructions on the "advanced setup" page are not really applicable as the Angular build system does not integrate with Babel. So it doesn't seem possible to execute the macros. Looking into it more, it seems that the macros are just used to substitute some prod vs dev functions and to implement an alternative deprecation syntax. Both of these seem pretty trivial at first glance. Maybe you can consider providing an option that does not depend on babel.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions