Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for amd options #663

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ Options
--compress Compress output using Terser
--strict Enforce undefined global context and add "use strict"
--name Specify name exposed in UMD and IIFE builds
--amd-name [amd] use named define("name", ...)
--amd-define [amd] function to use in place of define()
--cwd Use an alternative working directory (default .)
--sourcemap Generate source map (default true)
--raw Show raw byte size (default false)
Expand Down
10 changes: 10 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,15 @@ function createConfig(options, entry, format, writeMeta) {
outputAliases['.'] = './' + basename(options.output);
}

let amd = {};
if (options['amd-name']) {
amd.id = options['amd-name'];
}

if (options['amd-define']) {
amd.define = options['amd-define'];
}

const moduleAliases = options.alias
? parseMappingArgumentAlias(options.alias)
: [];
Expand Down Expand Up @@ -707,6 +716,7 @@ function createConfig(options, entry, format, writeMeta) {
outputOptions: {
paths: outputAliases,
globals,
amd,
strict: options.strict === true,
legacy: true,
freeze: false,
Expand Down
2 changes: 2 additions & 0 deletions src/prog.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export default handler => {
.option('--compress', 'Compress output using Terser', null)
.option('--strict', 'Enforce undefined global context and add "use strict"')
.option('--name', 'Specify name exposed in UMD builds')
.option('--amd-name', '[amd] use named define("name", ...)')
.option('--amd-define', '[amd] function to use in place of define()')
.option('--cwd', 'Use an alternative working directory', '.')
.option('--sourcemap', 'Generate source map', true)
.option(
Expand Down