exporting a variable from server side js file to client side js file

Why does the client side file attempt to read the entire server side file despite my explicit export statement targeting a simple object variable?

It has to execute the code in the module to get the result.

It has no way of knowing that line 1 isn’t needed but lines 3-8 are.

If you import a module, you import a module. The destructuring operation is done on the whole object exported by the module.


If you’re outputting data and not code then don’t use a module. Have the browser request JSON with Ajax. You don’t need to change the web scraper so it outputs the data differently. You can write a web service end point in your server that imports the module you already have and makes the data in it available.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top