# How to export a JavaScript module to multiple formats

DevFeed: [How to export a JavaScript module to multiple formats](<https://devfeed.tech/articles/how-to-export-a-javascript-module-to-multiple-formats-27938.md>)

Original publisher: [Read original article](<https://tech.trivago.com/post/2015-12-17-export-multiple-javascript-module-formats/>)

Author: Tom Bartel

Published: 2015-12-17T00:00:00Z

Content type: tutorial

Language: en

Sources: [Trivago](<https://devfeed.tech/sources/trivago.md>)

Topics: [JavaScript](<https://devfeed.tech/topics/javascript.md>), [Webpack](<https://devfeed.tech/topics/webpack.md>), [Library](<https://devfeed.tech/topics/library.md>), [CommonJS](<https://devfeed.tech/topics/commonjs.md>), [modules](<https://devfeed.tech/topics/modules.md>), [es6](<https://devfeed.tech/topics/es6.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>)

Tags: [article](<https://devfeed.tech/tags/article.md>), [build](<https://devfeed.tech/tags/build.md>), [code](<https://devfeed.tech/tags/code.md>), [commonjs](<https://devfeed.tech/tags/commonjs.md>), [es6](<https://devfeed.tech/tags/es6.md>), [frontend](<https://devfeed.tech/tags/frontend.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [webpack](<https://devfeed.tech/tags/webpack.md>)

## AI overview

This tutorial explains how to use webpack to publish a JavaScript library in multiple module formats, including CommonJS, AMD, ES6, global-variable, and UMD formats. It covers the libraryTarget configuration and using multiple compiler runs for different build targets.

## Source excerpt

When publishing a JavaScript library, we usually want to make it available to as many people as possible to maximize the library's usefulness and adoption. In that respect, it can be helpful to users to have the library available in their preferred module format - CommonJS, AMD, ES6, etc.