Using several JS files in StackBlitz with a simple JS-project
Asked Answered
C

2

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?

Campion answered 13/9, 2018 at 19:24 Comment(0)
C
10

in index.js:

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

In myscript.js:

exports.func = function(){...}
Cusick answered 19/10, 2018 at 17:41 Comment(4)
But then how do you use a function described in myscript.js inside index.js ?Rossen
@CodyBugstein, like this: stackblitz.com/edit/svelte-imozn2?file=index.jsBraddock
Can you also take a look at this question? #52899165Rossen
(btw I cannot award bounty for another 21 hours, but I will asap)Rossen
W
4

I have tried this and worked for me.

In index.js add below statement

import "./myscript.js";
Weatherman answered 24/10, 2020 at 17:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.