When working with vanilla JS, I am able to include a script like this:
<head>
<script src="https://api.site.com/js/v1/script.js"></script>
</head>
and then create an instance of it using:
const fn = ScriptJS();
I can then use it like so:
const someOutput = fn.execute({input})
However, when trying to achieve the same thing in NextJS (with TypeScript), I am encountering reference errors and dynamic import issues.
I'm wondering if I need to declare a type?
Using a <script>
tag in thepage.tsx results in a
ReferenceError: Script is not defined
Using a <script>
tag in _app.tsx also gives a
ReferenceError: Script is not defined
Attempting to load via require() or import() throws
The target environment doesn't support dynamic import() syntax so it's not possible to use external type 'module' within a script