> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt ## Resource: Module Export Syntax ## Article: Module Export Syntax ## Article Link: https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/java-script-velo/module-export-syntax.md ## Article Content: # Module Export Syntax Wix supports working in JavaScript to develop websites, as well as [support for modules](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/java-script-velo/java-script-support.md#module-support-ecmascript-2015). This allows you to export modules from your code files and import them into your other code files. This article explains the supported syntax for exporting modules. ## Supported IDEs You can export modules in: + The [editor](https://dev.wix.com/docs/develop-websites/articles/workspace-tools/velo-workspace/workspaces/wix-studio-working-with-the-code-panel.md) (Wix Studio and Wix Editor). + The [Wix IDE](https://dev.wix.com/docs/develop-websites/articles/workspace-tools/velo-workspace/wix-ide/wix-studio-about-the-wix-ide.md) (Wix Studio). + Your [local IDE](https://dev.wix.com/docs/develop-websites/articles/workspace-tools/developer-tools/git-integration-wix-cli-for-sites/about-git-integration-wix-cli-for-sites.md) (Wix Studio and Wix Editor). ## Supported syntax When exporting functions in the following files, use the standard export syntax contained in the documentation's code examples: + [`events.js`](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/backend-code/events/about-backend-events.md) + [`data.js`](https://dev.wix.com/docs/develop-websites/articles/databases/wix-data/hooks/using-data-hooks.md) + [`routers.js`](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/routers/about-routers.md) + [Service plugin code files](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/integrations/service-plugins-formerly-spis/about-service-plugins.md) You can also use other export formats that are part of the [ES6 (ES2015) module export syntax](https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/export). However, the following export formats are **not** supported in `events.js`, `data.js`, `routers.js`, or service plugin code files: + **Re-exporting a function:** Directly re-exporting a function imported from an npm or Velo package. For example, this **doesn't** work: ```javascript import { myFunction } from 'myPackage'; export const wixMediaManager_onFileUploaded = myFunction; ``` The following alternative syntax **is** supported: ```javascript import { myFunction } from 'myPackage'; export const wixMediaManager_onFileUploaded = (paramA, paramB) => myFunction(paramA, paramB); ``` + **Dynamic exports:** Exports including a dynamic operation or expression that requires execution to resolve. For example, this **doesn't** work: ```javascript import myPackage from 'myPackage'; export const myRouter_Router = myPackage.router((paramA, paramB) => { // ... }); ``` The following alternative syntax **is** supported: ```javascript import myPackage from 'myPackage'; const functionForExport = myPackage.router((paramA, paramB) => { // ... }) export const myRouter_Router = (paramA, paramB) => functionForExport(paramA, ParamB); ``` + **Exports wrapped in objects:** Exports where functions are defined as properties of an object. For example, this **doesn't** work: ```javascript const dataHooks = { beforeInsert: (paramA, paramB) => { // ... } }; export const MyCollection_beforeInsert = dataHooks.beforeInsert; ``` The following alternative syntax **is** supported: ```javascript const dataHooks = { beforeInsert: (paramA, paramB) => { // ... } }; export const MyCollection_beforeInsert = (paramA, paramB) => dataHooks.beforeInsert(paramA, paramB); ``` + **CommonJS exports:** Exports in the CommonJS (CJS) format that preceded ES6 (ES2015). For example, this **doesn't** work: ```javascript module.exports = { MyCollection_beforeInsert: () => {} }; ``` ## See also + [About JavaScript support](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/java-script-velo/java-script-support.md)