[FEATURE] Add minify task and processor#666
Conversation
0877d46 to
167af6b
Compare
fb813f6 to
9b5eddf
Compare
|
Tests are failing because of dependency to SAP/ui5-fs#331 |
| const LocatorResource = require("./LocatorResource"); | ||
|
|
||
| class LocatorResourcePool extends ResourcePool { | ||
| constructor({ignoreMissingModules} = {}) { |
lib/lbt/resources/ResourcePool.js
Outdated
|
|
||
| async function determineDependencyInfo(resource, rawInfo, pool) { | ||
| const info = new ModuleInfo(resource.name); | ||
| const info = new ModuleInfo(ModuleName.getNonDebugName(resource.name) || resource.name); |
lib/processors/minifier.js
Outdated
| dbgResource.setPath(dbgPath); | ||
|
|
||
| const filename = path.posix.basename(resource.getPath()); | ||
| if (filename.endsWith(".support.js")) { |
There was a problem hiding this comment.
AFAIK this is the reason why it should not be done
| if (filename.endsWith(".support.js")) { | |
| // Support rules should not be minified to have readable code in the Support Assistant | |
| if (filename.endsWith(".support.js")) { |
There was a problem hiding this comment.
Done, moved to glob pattern in Application- and LibraryBuilder
|
|
||
| return Promise.all(processedResources.map(async ({resource, dbgResource, sourceMapResource}) => { | ||
| if (taskUtil) { | ||
| taskUtil.setTag(resource, taskUtil.STANDARD_TAGS.HasDebugVariant); |
There was a problem hiding this comment.
Is this really correct for the "*.support.js" files?
I would expect that those should be skipped completely (no tags set).
test/lib/processors/minifier.js
Outdated
| t.deepEqual(await resources[3].resource.getPath(), "/test4.support.js", | ||
| "Correct resource path for minified content of resource 4"); | ||
| t.deepEqual(await resources[3].resource.getString(), expectedMinified4, "Correct minified content for resource 4"); | ||
| t.deepEqual(await resources[3].dbgResource.getPath(), "/test4-dbg.support.js", |
There was a problem hiding this comment.
This assertion should fail, right?
There was a problem hiding this comment.
Not relevant anymore, minifier now has no special handling of support files.
test/lib/processors/minifier.js
Outdated
| `{"version":3,"sources":["test3-dbg.designtime.js"],"names":["test3","paramA","variableA","console","log"],` + | ||
| `"mappings":"AACA,SAASA,MAAMC,GACd,IAAIC,EAAYD,EAChBE,QAAQC,IAAIF,GAEbF","file":"test3.designtime.js"}`; | ||
|
|
||
| t.deepEqual(await resources[0].resource.getPath(), "/test1.controller.js", |
| }).transformer(async function(resourcePath, getClonedResource) { | ||
| if (taskUtil.getTag(resourcePath, taskUtil.STANDARD_TAGS.IsDebugVariant)) { | ||
| const resource = await getClonedResource(); |
There was a problem hiding this comment.
| }).transformer(async function(resourcePath, getClonedResource) { | |
| if (taskUtil.getTag(resourcePath, taskUtil.STANDARD_TAGS.IsDebugVariant)) { | |
| const resource = await getClonedResource(); | |
| }).transformer(async function(resourcePath, getResource) { | |
| if (taskUtil.getTag(resourcePath, taskUtil.STANDARD_TAGS.IsDebugVariant)) { | |
| const resource = await getResource(); |
| "version":"2.0", | ||
| "modules":{ | ||
| "application/i/Component.js":function(){sap.ui.define(["sap/ui/core/UIComponent"],function(n){"use strict";return n.extend("application.i.Component",{metadata:{manifest:"json"}})}); | ||
| //# sourceMappingURL=Component.js.map |
There was a problem hiding this comment.
Should those comments be part of the preload? If the browser ignores them I guess it's okay. If it causes problems, we should remove them.
There was a problem hiding this comment.
I think they are not a problem unless they are at the end of the file. Anyways, the source map change for the module bundler will remove them 👍
There was a problem hiding this comment.
As already mentioned above: We don't want to create -dbg files for *.support.js files. So they should just remain as-is.
8a71cde to
a6ad03a
Compare
Combines debug-file creation, source-map generation and minification. Replaces existing tasks/processors 'uglify' and 'createDebugFiles'. BREAKING CHANGE: The following tasks have been removed: - createDebugFiles - uglify The following processors have been removed: - debugFileCreator - resourceCopier - uglifier As a replacement, the new 'minify' task and 'minifier' processors can be used. Note: The minify task is now executed earlier, before the bundling process takes place. The 'beforeTask' and 'afterTask' configuration of custom tasks might need to be adapted to cater for this change.
Bundling can now rely on preceding minify task
…ix error message Do not check whether a debug-variant already exists. Just overwrite it
…ith and without minify task
Only for bundles configured as 'optimize: false'. Removes LocatorResourcePool option to remove -dbg from resource names.
…unoptimized sap.ui.core bundles Only applicable to sap.ui.core versions <1.97.0. Same logic as for custom bundles in the generateBundle task.
Without building all dependencies, some modules might not be minified now
…uilder instead of explicit implementation
a6ad03a to
c6c1e84
Compare
|
Rebased on top of latest |
lib/tasks/TaskUtil.js
Outdated
| return this._projectBuildContext.getResourceTagCollection().clearTag(resourcePath, tag); | ||
| } | ||
|
|
||
| getResourceTagCollection() { |
There was a problem hiding this comment.
But.. is this method actually used somewhere?
I couldn't find a reference.
There was a problem hiding this comment.
Right, this shouldn't be necessary anymore. Probably it was added for some different, intermediate implementation.
| `unable to generate complete bundles for such projects.`); | ||
| } | ||
|
|
||
| // If an application does not have a namespace, its resources are located at the root. Otherwise in /resources |
There was a problem hiding this comment.
By removing this behavior, we need to make sure to fail in case we don't have a namespace (as already planned for 3.0)
Combines debug-file creation, source-map generation and minification. Replaces existing tasks/processors 'uglify' and 'createDebugFiles'. Also introduce new global tags `IsDebugVariant` and `HasDebugVariant`. BREAKING CHANGE: The following tasks have been removed: - createDebugFiles - uglify The following processors have been removed: - debugFileCreator - resourceCopier - uglifier As a replacement, the new 'minify' task and 'minifier' processor can be used. Note: The minify task is executed earlier, before the bundling process takes place. Existing 'beforeTask' and 'afterTask' configuration of custom tasks might need to be adapted to cater for this change.
Implements UI5/cli#583 based on #657
Depends on SAP/ui5-fs#331
minifytaskuglifyandcreateDebugFilestasksIsDebugVariantoptimizebundleOption)Open TODOs:
optimize: truebundle generation without minify taskoptimize: falsebundle generation with minify task