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

Expose browserify sourcemap feature in plugin interface. #115

Open
wants to merge 1 commit 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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Configuration options can be set globally in `custom` property and inside each f
* **plugins** - Array of Babel plugins.
* **prefix** (default `_optimize`) - Folder to output bundle.
* **presets** (default `['env']`) - Array of Babel presets.
* **sourceMaps** (default `false`) - when set to `true` an inline sourcemap is generated. This improves stack trace error messages for minified source files. To enable Lambda to use the generated sourcemap you need to enable the feature using the environment variable `NODE_OPTIONS: --enable-source-maps`.

```yml
custom:
Expand All @@ -71,6 +72,7 @@ custom:
prefix: 'dist'
plugins: ['transform-decorators-legacy']
presets: ['es2017']
sourceMaps: true
```

#### Function
Expand All @@ -93,6 +95,7 @@ functions:
* **minify** - When minify is set to `false` Babili preset won't be added.
* **plugins** - Array of Babel plugins.
* **presets** - Array of Babel presets.
* **sourceMaps** (default `false`) - when set to `true` an inline sourcemap is generated. This improves stack trace error messages for minified source files. To enable Lambda to use the generated sourcemap you need to enable the feature using the environment variable `NODE_OPTIONS: --enable-source-maps`.

```yml
functions:
Expand All @@ -109,6 +112,7 @@ functions:
minify: false
     plugins: ['transform-decorators-legacy']
     presets: ['es2017']
sourceMaps: true
```

#### includePaths Files
Expand Down
14 changes: 11 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ class Optimize {
targets: {
node: nodeVersion
}
}]]
}]],
sourceMaps: false
}
}

Expand Down Expand Up @@ -144,6 +145,11 @@ class Optimize {
if (Array.isArray(this.custom.optimize.presets)) {
this.optimize.options.presets = this.custom.optimize.presets
}

/** Source maps */
if (typeof this.custom.optimize.sourceMaps === 'boolean') {
this.optimize.options.sourceMaps = this.custom.optimize.sourceMaps
}
}

/** Serverless hooks */
Expand Down Expand Up @@ -323,7 +329,8 @@ class Optimize {
ignore: this.optimize.options.ignore,
minify: this.optimize.options.minify,
plugins: this.optimize.options.plugins,
presets: this.optimize.options.presets
presets: this.optimize.options.presets,
sourceMaps: this.optimize.options.sourceMaps
}

if (functionObject.optimize) {
Expand Down Expand Up @@ -393,7 +400,8 @@ class Optimize {
global: undefined,
'Buffer.isBuffer': undefined,
Buffer: undefined
}
},
debug: functionOptions.sourceMaps
})

/** Browserify exclude */
Expand Down