Skip to content
v2.277.0

LogLevel Enum ​

Log levels for esbuild and package managers' install commands.

Example ​

ts
new nodejs.NodejsFunction(this, 'my-handler', {
  bundling: {
    minify: true, // minify code, defaults to false
    sourceMap: true, // include source map, defaults to false
    sourceMapMode: nodejs.SourceMapMode.INLINE, // defaults to SourceMapMode.DEFAULT
    sourcesContent: false, // do not include original source into source map, defaults to true
    target: 'es2020', // target environment for the generated JavaScript code
    loader: { // Use the 'dataurl' loader for '.png' files
      '.png': 'dataurl',
    },
    define: { // Replace strings during build time
      'process.env.API_KEY': JSON.stringify('xxx-xxxx-xxx'),
      'process.env.PRODUCTION': JSON.stringify(true),
      'process.env.NUMBER': JSON.stringify(123),
    },
    logLevel: nodejs.LogLevel.ERROR, // defaults to LogLevel.WARNING
    keepNames: true, // defaults to false
    tsconfig: 'custom-tsconfig.json', // use custom-tsconfig.json instead of default,
    metafile: true, // include meta file, defaults to false
    banner: '/* comments */', // requires esbuild >= 0.9.0, defaults to none
    footer: '/* comments */', // requires esbuild >= 0.9.0, defaults to none
    charset: nodejs.Charset.UTF8, // do not escape non-ASCII characters, defaults to Charset.ASCII
    format: nodejs.OutputFormat.ESM, // ECMAScript module output format, defaults to OutputFormat.CJS (OutputFormat.ESM requires Node.js >= 14)
    mainFields: ['module', 'main'], // prefer ECMAScript versions of dependencies
    inject: ['./my-shim.js', './other-shim.js'], // allows you to automatically replace a global variable with an import from another file
    esbuildArgs: { // Pass additional arguments to esbuild
      "--log-limit": "0",
      "--splitting": true,
    },
  },
});
python
nodejs.NodejsFunction(self, "my-handler",
    bundling=nodejs.BundlingOptions(
        minify=True,  # minify code, defaults to false
        source_map=True,  # include source map, defaults to false
        source_map_mode=nodejs.SourceMapMode.INLINE,  # defaults to SourceMapMode.DEFAULT
        sources_content=False,  # do not include original source into source map, defaults to true
        target="es2020",  # target environment for the generated JavaScript code
        loader={ # Use the 'dataurl' loader for '.png' files
            ".png": "dataurl"},
        define={ # Replace strings during build time
            "process.env.API_KEY": JSON.stringify("xxx-xxxx-xxx"),
            "process.env.PRODUCTION": JSON.stringify(True),
            "process.env.NUMBER": JSON.stringify(123)},
        log_level=nodejs.LogLevel.ERROR,  # defaults to LogLevel.WARNING
        keep_names=True,  # defaults to false
        tsconfig="custom-tsconfig.json",  # use custom-tsconfig.json instead of default,
        metafile=True,  # include meta file, defaults to false
        banner="/* comments */",  # requires esbuild >= 0.9.0, defaults to none
        footer="/* comments */",  # requires esbuild >= 0.9.0, defaults to none
        charset=nodejs.Charset.UTF8,  # do not escape non-ASCII characters, defaults to Charset.ASCII
        format=nodejs.OutputFormat.ESM,  # ECMAScript module output format, defaults to OutputFormat.CJS (OutputFormat.ESM requires Node.js >= 14)
        main_fields=["module", "main"],  # prefer ECMAScript versions of dependencies
        inject=["./my-shim.js", "./other-shim.js"],  # allows you to automatically replace a global variable with an import from another file
        esbuild_args={ # Pass additional arguments to esbuild
            "--log-limit": "0",
            "--splitting": True}
    )
)
java
NodejsFunction.Builder.create(this, "my-handler")
        .bundling(BundlingOptions.builder()
                .minify(true) // minify code, defaults to false
                .sourceMap(true) // include source map, defaults to false
                .sourceMapMode(SourceMapMode.INLINE) // defaults to SourceMapMode.DEFAULT
                .sourcesContent(false) // do not include original source into source map, defaults to true
                .target("es2020") // target environment for the generated JavaScript code
                .loader(Map.of( // Use the 'dataurl' loader for '.png' files
                        ".png", "dataurl"))
                .define(Map.of( // Replace strings during build time
                        "process.env.API_KEY", JSON.stringify("xxx-xxxx-xxx"),
                        "process.env.PRODUCTION", JSON.stringify(true),
                        "process.env.NUMBER", JSON.stringify(123)))
                .logLevel(LogLevel.ERROR) // defaults to LogLevel.WARNING
                .keepNames(true) // defaults to false
                .tsconfig("custom-tsconfig.json") // use custom-tsconfig.json instead of default,
                .metafile(true) // include meta file, defaults to false
                .banner("/* comments */") // requires esbuild >= 0.9.0, defaults to none
                .footer("/* comments */") // requires esbuild >= 0.9.0, defaults to none
                .charset(Charset.UTF8) // do not escape non-ASCII characters, defaults to Charset.ASCII
                .format(OutputFormat.ESM) // ECMAScript module output format, defaults to OutputFormat.CJS (OutputFormat.ESM requires Node.js >= 14)
                .mainFields(List.of("module", "main")) // prefer ECMAScript versions of dependencies
                .inject(List.of("./my-shim.js", "./other-shim.js")) // allows you to automatically replace a global variable with an import from another file
                .esbuildArgs(Map.of( // Pass additional arguments to esbuild
                        "--log-limit", "0",
                        "--splitting", true))
                .build())
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
new NodejsFunction(this, "my-handler", new NodejsFunctionProps {
    Bundling = new BundlingOptions {
        Minify = true,  // minify code, defaults to false
        SourceMap = true,  // include source map, defaults to false
        SourceMapMode = SourceMapMode.INLINE,  // defaults to SourceMapMode.DEFAULT
        SourcesContent = false,  // do not include original source into source map, defaults to true
        Target = "es2020",  // target environment for the generated JavaScript code
        Loader = new Dictionary<string, string> {  // Use the 'dataurl' loader for '.png' files
            { ".png", "dataurl" } },
        Define = new Dictionary<string, string> {  // Replace strings during build time
            { "process.env.API_KEY", JSON.Stringify("xxx-xxxx-xxx") },
            { "process.env.PRODUCTION", JSON.Stringify(true) },
            { "process.env.NUMBER", JSON.Stringify(123) } },
        LogLevel = LogLevel.ERROR,  // defaults to LogLevel.WARNING
        KeepNames = true,  // defaults to false
        Tsconfig = "custom-tsconfig.json",  // use custom-tsconfig.json instead of default,
        Metafile = true,  // include meta file, defaults to false
        Banner = "/* comments */",  // requires esbuild >= 0.9.0, defaults to none
        Footer = "/* comments */",  // requires esbuild >= 0.9.0, defaults to none
        Charset = Charset.UTF8,  // do not escape non-ASCII characters, defaults to Charset.ASCII
        Format = OutputFormat.ESM,  // ECMAScript module output format, defaults to OutputFormat.CJS (OutputFormat.ESM requires Node.js >= 14)
        MainFields = new [] { "module", "main" },  // prefer ECMAScript versions of dependencies
        Inject = new [] { "./my-shim.js", "./other-shim.js" },  // allows you to automatically replace a global variable with an import from another file
        EsbuildArgs = new Dictionary<string, object> {  // Pass additional arguments to esbuild
            { "--log-limit", "0" },
            { "--splitting", true } }
    }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
nodejs.NewNodejsFunction(this, jsii.String("my-handler"), &NodejsFunctionProps{
	Bundling: &BundlingOptions{
		Minify: jsii.Boolean(true),
		 // minify code, defaults to false
		SourceMap: jsii.Boolean(true),
		 // include source map, defaults to false
		SourceMapMode: nodejs.SourceMapMode_INLINE,
		 // defaults to SourceMapMode.DEFAULT
		SourcesContent: jsii.Boolean(false),
		 // do not include original source into source map, defaults to true
		Target: jsii.String("es2020"),
		 // target environment for the generated JavaScript code
		Loader: map[string]*string{
			 // Use the 'dataurl' loader for '.png' files
			".png": jsii.String("dataurl"),
		},
		Define: map[string]*string{
			 // Replace strings during build time
			"process.env.API_KEY": JSON.stringify(jsii.String("xxx-xxxx-xxx")),
			"process.env.PRODUCTION": JSON.stringify(jsii.Boolean(true)),
			"process.env.NUMBER": JSON.stringify(jsii.Number(123)),
		},
		LogLevel: nodejs.LogLevel_ERROR,
		 // defaults to LogLevel.WARNING
		KeepNames: jsii.Boolean(true),
		 // defaults to false
		Tsconfig: jsii.String("custom-tsconfig.json"),
		 // use custom-tsconfig.json instead of default,
		Metafile: jsii.Boolean(true),
		 // include meta file, defaults to false
		Banner: jsii.String("/* comments */"),
		 // requires esbuild >= 0.9.0, defaults to none
		Footer: jsii.String("/* comments */"),
		 // requires esbuild >= 0.9.0, defaults to none
		Charset: nodejs.Charset_UTF8,
		 // do not escape non-ASCII characters, defaults to Charset.ASCII
		Format: nodejs.OutputFormat_ESM,
		 // ECMAScript module output format, defaults to OutputFormat.CJS (OutputFormat.ESM requires Node.js >= 14)
		MainFields: []*string{
			jsii.String("module"),
			jsii.String("main"),
		},
		 // prefer ECMAScript versions of dependencies
		Inject: []*string{
			jsii.String("./my-shim.js"),
			jsii.String("./other-shim.js"),
		},
		 // allows you to automatically replace a global variable with an import from another file
		EsbuildArgs: map[string]interface{}{
			 // Pass additional arguments to esbuild
			"--log-limit": jsii.String("0"),
			"--splitting": jsii.Boolean(true),
		},
	},
})

Members ​

MemberDescription
VERBOSEShow everything.
DEBUGShow everything from info and some additional messages for debugging.
INFOShow warnings, errors, and an output file summary.
WARNINGShow warnings and errors.
ERRORShow errors only.
SILENTShow nothing.

Referenced by ​