Angular update triggers '$' error in Docs add-on

After updating Angular from 14 to 17, my Google Docs add-on errors on ‘$’. The issue appears in the add-on container; disabling a webpack plugin did not fix it.

hey, had similar trouble upgrading. try adding ‘@angular/platform-browser-dynamic’ to ur imports. fixed the ‘$’ thing for me. also check ur tsconfig, might need tweaking. good luck mate!

I encountered a similar issue when upgrading Angular in a Google Workspace add-on project. The ‘$’ error often stems from changes in how Angular handles global variables and jQuery-like syntax.

One solution that worked for me was explicitly importing and declaring ‘$’ as a global variable. In your main TypeScript file, try adding:

declare global {
  interface Window {
    $: any;
  }
}

Then, in your component files where you use ‘$’, import it like this:

import { $ } from 'jquery';

Additionally, ensure your tsconfig.json includes ‘dom’ in the ‘lib’ array under ‘compilerOptions’. This helped resolve some jQuery-related issues for me.

If these steps don’t work, you might need to review your webpack configuration to ensure it’s compatible with Angular 17’s module system. Good luck with the upgrade!

Having dealt with Angular upgrades in Google Workspace add-ons, I can say it’s often tricky. The ‘$’ error you’re seeing might be related to how Angular 17 handles global variables differently. One approach that’s worked for me is to use the ‘ngx-google-analytics’ package instead of relying on the global ‘$’. It’s specifically designed for Angular and Google services integration.

Another thing to check is your polyfills.ts file. Make sure it’s up to date with Angular 17 requirements. Sometimes, older polyfills can cause conflicts with newer Angular versions in the Google Docs environment.

If those don’t help, you might need to dig into your webpack config. Look for any plugins or loaders that might be interfering with Angular’s new module system. It’s a bit of a pain, but usually solvable with some careful configuration tweaking.