Module Export Syntax

Wix supports working in JavaScript to develop websites, as well as support for modules. 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 (Wix Studio and Wix Editor).
  • The Wix IDE (Wix Studio).
  • Your local IDE (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:

You can also use other export formats that are part of the ES6 (ES2015) module export syntax. 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:

    Copy

    The following alternative syntax is supported:

    Copy
  • Dynamic exports: Exports including a dynamic operation or expression that requires execution to resolve. For example, this doesn't work:

    Copy

    The following alternative syntax is supported:

    Copy
  • Exports wrapped in objects: Exports where functions are defined as properties of an object. For example, this doesn't work:

    Copy

    The following alternative syntax is supported:

    Copy
  • CommonJS exports: Exports in the CommonJS (CJS) format that preceded ES6 (ES2015). For example, this doesn't work:

    Copy

See also

Did this help?