12

In StackBlitz it's possible to add another JS file(s) (besides index.js) but it seems that only index.js is actually being loaded. All the functions defined in other JS files created in the same (root) folder are just undefined when I try to call them within the index.js. I tried to 'activate' other files via HTML (<script src='./filename.js'> tag) but it didn't help. What am I doing wrong?

2 Answers 2

10
+50

in index.js:

import {func} from './myscript.js';

In myscript.js:

exports.func = function(){...}
Sign up to request clarification or add additional context in comments.

4 Comments

But then how do you use a function described in myscript.js inside index.js ?
Can you also take a look at this question? stackoverflow.com/questions/52898665/…
(btw I cannot award bounty for another 21 hours, but I will asap)
4

I have tried this and worked for me.

In index.js add below statement

import "./myscript.js";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.