Modules for the browser,
ES6, and CommonJS
(Drakon.Tech JavaScript tutorial)https://www.youtube.com/watch?time_cont ... R0Xd-3V4DoЦитата:
DRAKON Visual Language
Опубликовано: 11 мая 2019 г.
How to organize JavaScript code with modules of different types:
- CommonJS
- ES6
- Factory functions
- IIFE
https://drakon.tech/Examples:
https://app.drakon.tech/ide/doc/examp...
Цитата:
How to make a JavaScript module
Create a module in a Drakon.Tech project.
Right-click on the module.
Click on "Properties".
Set the language to "JavaScript".
Save the properties.
Click the "Build" button on the top menu.
A Drakon.Tech module becomes a JS file, if the module language is "JavaScript."
How to change the module type
Right-click on the module in Drakon.Tech.
Click on "Properties".
Set the "Module format".
Save the properties.
Available module formats:
IIFE - immediately invoked function expression
Factory
CommonJS
ES6
How to export a function
Put the "export" keyword in the first line of the "Parameters" icon.
This works for Factory, CommonJS, and ES6 module types.
Note: for IIFE module type, exported functions need to be manually saved in the global scope.
An exported function: