diff --git a/README.md b/README.md index 249a230d..d4cc405c 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/src/index.js b/src/index.js index a10ae135..24dff453 100644 --- a/src/index.js +++ b/src/index.js @@ -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) : []; @@ -707,6 +716,7 @@ function createConfig(options, entry, format, writeMeta) { outputOptions: { paths: outputAliases, globals, + amd, strict: options.strict === true, legacy: true, freeze: false, diff --git a/src/prog.js b/src/prog.js index 8386f9c5..ccea5431 100644 --- a/src/prog.js +++ b/src/prog.js @@ -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(