krasimir / hopa

Zero config CLI for running JavaScript/TypeScript files

Home Page:https://krasimirtsonev.com/blog/article/hopa-javascript-typescript-runner

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uncaught ReferenceError: exports is not defined

dannysmc95 opened this issue · comments

So I am using this to convert browser libraries, to a single bundle, but I have noticed that the following shows up:

Uncaught ReferenceError: exports is not defined

I have seen this on EVERY other program that compiles to browser, is there anything I can do to fix this? I am using TypeScript to write the modules, then creating a single bundle that I can then load into the browser?

Thanks,

Can you prepare an example. Like for example a public repo that I can try on my machine + the hopa command that you use.

Hi @krasimir ,

Created below:
https://github.com/dannysmc95/hopa-issue-1

If you just load the index.html file and open it into your browser and look at the console, that is a recently compiled file, and it just errors.

So was wondering what I can do to fix it? At the moment, I have some code that is writing
var exports = {}

At the top of the file so it does not error.

Oh I see now. This feature of Hopa is quite limited right now. I didn't find a way to make it work as expected but will play with with it soon. For now the main usage of the library is running stuff on the fly and not exactly producing bundles.

Hi @krasimir , yeah I noticed that the more I tried to tweak it, I will look elsewhere for the time being, but as you expand it please let me know!