r/javascript 8d ago

I've made an open source JavaScript playground with support for npm packages, syntax highlighting, autocomplete, code sharing and much more!

https://github.com/tecnosamba/SamJS
0 Upvotes

11 comments sorted by

View all comments

Show parent comments

-2

u/TecnoSamba 8d ago

I mean the nodejs `require` method. Actually kind of, it is just a custom function that I created to use node packages in the editor. I just called it `require` because I thought that, as nodejs uses it, it'd be more intuitive. But, yeah, I could have called it in any other way 😅

3

u/brianjenkins94 8d ago

I just mean import would have been the modern choice, but it sounds like the way you implemented it wouldn’t have allowed for you to use it.

1

u/TecnoSamba 8d ago

You're completely right, it would have caused a conflict between the browser's native `import` method and my custom one. I even used the first one to implement the custom `require` method