-
Notifications
You must be signed in to change notification settings - Fork 664
Description
When writing a custom AMD plugin builder, it can be valuable to know the layer module id and path of the layer currently being flattened. Currently these fields are passed to onLayerEnd
, but not to write
.
Proposal:
Add this information to 'writeApi' (3rd argument to builder.write), for example as layerName
and layerPath
properties. Alternatively a 4th argument could be added.
(This is basically the information that is on module.onCompleteData
, without the includes
Array).
Reason:
Any custom plugin that combines multiple files into a single file (probably as a sibling of the layer js file), needs to add "no-op" mappings for the source files it optimized. These mappings need to be added during write
. It is currently impossible to do any logic that refers to the combined module the plugin builder will generate in onLayerEnd
.
My specific use case is a custom CSS loader that will combine CSS files into a single my/layer/module.css
when building the layer my/layer/module
. It would be very useful if the no-op define
inserted during the build could return the module id of the css file that the file got optimized into.
For example, it may want to insert this on write
:
define( 'css!my/module/button.css', [], function(){ return "my/layer/module.css"; } );