How to import polyfill module

Motivation

I want use InteractionObserver in svg, but Chrome seems have a bug on this API(when apply it on nested svg element).

Question

So, how can i import a polypill module above all other imports?

Currently I use the %%raw, but it not work. my custom import is put bottom for all other import statement

image

I think the simplest, most pragmatic solution is to have your entrypoint be a js file.

import 'intersection-observer'
import './App.bs.js'
2 Likes

You can also use %%raw() to import / require.

ie.

%%raw(`import "vite/modulepreload-polyfill"`)
%%raw(`import 'whatwg-fetch'`)