+ 5

Code Bits ES6 Module

is it possible to use es6 module in code bits/playground ? because we cant really modify the script tag here https://www.sololearn.com/discuss/1727204/?ref=app related topic i can find, not really answer how. all i have is an error "cannot use import outside module" when trying to import a module

15th Jul 2020, 1:21 PM
Taste
Taste - avatar
18 Answers
+ 5
Calvin created a demo for dynamic importing a js module a couple of months ago. It may help solve your dilemma. https://code.sololearn.com/WoR3yeFp6pSe/#html You will need to change the source due to CORS 'https://cors-anywhere.herokuapp.com/https://testmod.glitch.me/test.js'
15th Jul 2020, 3:24 PM
ODLNT
ODLNT - avatar
+ 5
Taste ES6 Modules are supported in Playground. Just leave the src attribute out of the following line: <script type="module"> import a from src_url </script> I've created a simple demo to show that import from external reference does load. https://code.sololearn.com/WGsS5OnXK3In/?ref=app
15th Jul 2020, 3:41 PM
David Carroll
David Carroll - avatar
+ 2
Taste Ohh So you mean Sololearn link the html , css and js automatically.. Yeah That is a problem then.. From my side I see no solution. You could contact the team though.
15th Jul 2020, 1:49 PM
Saphal Poudyal
Saphal Poudyal - avatar
+ 2
yes, but the completed project need ES6 module.. i guess there's no other way than bloat the html page with the js
15th Jul 2020, 2:39 PM
Taste
Taste - avatar
+ 2
i do use github, the master plan of this code i'm working on is creating collaborative project between sololearn user. who know how it'll work or not
15th Jul 2020, 2:44 PM
Taste
Taste - avatar
+ 1
Totally off topic but you do not see a dog helping a cat everyday.
15th Jul 2020, 3:33 PM
Saphal Poudyal
Saphal Poudyal - avatar
+ 1
it was my solution, but doesnt optimal with 200+ lines of js. SL editor in my device start lagging around 150lines of codes
15th Jul 2020, 3:46 PM
Taste
Taste - avatar
0
Taste You mean like use ES6 features in code playground?
15th Jul 2020, 1:29 PM
Saphal Poudyal
Saphal Poudyal - avatar
0
the module feature to be exact like import { a } from "http://example.com/a_module.js"
15th Jul 2020, 1:29 PM
Taste
Taste - avatar
0
Taste Do other es6 features work?
15th Jul 2020, 1:35 PM
Saphal Poudyal
Saphal Poudyal - avatar
0
it should. the main problem with es6 module is i need a type attribute for the script tag <script type="module" src="script.js"> but code bits/playground import the js code automaticly to html.
15th Jul 2020, 1:38 PM
Taste
Taste - avatar
0
For me..!!! Do code in ur regular code editors..!! Like VS code, Sublime, etc... SoloLearn is juzt a platform to exhibit ur completed projects.. Best way to use ES6 Modules r only in ur personal PC 😁 PS : All these r my exp wordz.. not to insist anything wrong😊
15th Jul 2020, 2:36 PM
✨ Muviee ✨
✨ Muviee ✨ - avatar
0
Yup... I do think so..!!! I'd suggest u to publish ur code on some other good platforms😅 GitHub is there...!!
15th Jul 2020, 2:41 PM
✨ Muviee ✨
✨ Muviee ✨ - avatar
0
oooooh yes, its totally possible
15th Jul 2020, 3:30 PM
Taste
Taste - avatar
16th Jul 2020, 6:53 PM
Taste
Taste - avatar
0
Dffthdhdyxhyehxheyhet3yxhrhxhy4hxgegd hyd
17th Aug 2020, 7:52 PM
Sfrfrgrg5vthyhed4ff
0
Fctchhjbhvtvtvyh
17th Aug 2020, 7:52 PM
Sfrfrgrg5vthyhed4ff
0
Dxfctvghhhhhb6jtbuj
17th Aug 2020, 7:53 PM
Sfrfrgrg5vthyhed4ff