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

[BREAKING] Bundling: Enforce usage of sap.ui.predefine instead function wrappers #1021

Merged
merged 1 commit into from
May 28, 2024
Merged
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
74 changes: 36 additions & 38 deletions lib/lbt/bundle/Builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,52 +375,50 @@ class BundleBuilder {
}

async rewriteAMDModules(sequence) {
if ( this.options.usePredefineCalls ) {
const outW = this.outW;

const remaining = [];
for ( const moduleName of sequence ) {
if ( /\.js$/.test(moduleName) ) {
// console.log("Processing " + moduleName);
const resource = await this.pool.findResourceWithInfo(moduleName);
let moduleContent = (await resource.buffer()).toString();
let moduleSourceMap;
if (this.options.sourceMap) {
({moduleContent, moduleSourceMap} =
await this.getSourceMapForModule({
moduleName,
moduleContent,
resourcePath: resource.getPath()
}));
}
const outW = this.outW;

const rewriteRes = await rewriteDefine({
moduleName, moduleContent, moduleSourceMap
});
if (rewriteRes) {
const {moduleContent, moduleSourceMap} = rewriteRes;
outW.startSegment(moduleName);
outW.ensureNewLine();
if (moduleSourceMap) {
this.addSourceMap(moduleName, moduleSourceMap);
}
outW.write(moduleContent);
outW.ensureNewLine();
const compressedSize = outW.endSegment();
log.verbose(
` ${moduleName} (${resource.info != null ? resource.info.size : -1},${compressedSize})`);
} else {
// keep unprocessed modules
remaining.push(moduleName);
const remaining = [];
for ( const moduleName of sequence ) {
if ( /\.js$/.test(moduleName) ) {
// console.log("Processing " + moduleName);
const resource = await this.pool.findResourceWithInfo(moduleName);
let moduleContent = (await resource.buffer()).toString();
let moduleSourceMap;
if (this.options.sourceMap) {
({moduleContent, moduleSourceMap} =
await this.getSourceMapForModule({
moduleName,
moduleContent,
resourcePath: resource.getPath()
}));
}

const rewriteRes = await rewriteDefine({
moduleName, moduleContent, moduleSourceMap
});
if (rewriteRes) {
const {moduleContent, moduleSourceMap} = rewriteRes;
outW.startSegment(moduleName);
outW.ensureNewLine();
if (moduleSourceMap) {
this.addSourceMap(moduleName, moduleSourceMap);
}
outW.write(moduleContent);
outW.ensureNewLine();
const compressedSize = outW.endSegment();
log.verbose(
` ${moduleName} (${resource.info != null ? resource.info.size : -1},${compressedSize})`);
} else {
// keep unprocessed modules
remaining.push(moduleName);
}
} else {
// keep unprocessed modules
remaining.push(moduleName);
}

Array.prototype.splice.apply(sequence, [0, sequence.length].concat(remaining));
}

Array.prototype.splice.apply(sequence, [0, sequence.length].concat(remaining));
}

afterWriteFunctionPreloadSection() {
Expand Down
2 changes: 0 additions & 2 deletions lib/processors/bundlers/moduleBundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ const log = getLogger("builder:processors:bundlers:moduleBundler");
* with an optimization marker
* @property {boolean} [addTryCatchRestartWrapper=false] Whether to wrap bootable bundles with
* a try/catch to filter out "Restart" errors
* @property {boolean} [usePredefineCalls=false] If set to 'true', sap.ui.predefine is used for UI5 modules
* @property {number} [numberOfParts=1] The number of parts the module bundle should be splitted
* @property {boolean} [ignoreMissingModules=false] When searching for modules which are optional for further
* processing, do not throw in case they are missing
Expand Down Expand Up @@ -144,7 +143,6 @@ export default function({resources, options: {bundleDefinition, bundleOptions, m
sourceMap: true,
decorateBootstrapModule: false,
addTryCatchRestartWrapper: false,
usePredefineCalls: false,
numberOfParts: 1,
ignoreMissingModules: false
}, bundleOptions);
Expand Down
6 changes: 1 addition & 5 deletions lib/tasks/bundlers/generateLibraryPreload.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ function getModuleBundlerOptions(config) {
moduleBundlerOptions.bundleOptions = {
optimize: config.preload,
decorateBootstrapModule: config.preload,
addTryCatchRestartWrapper: config.preload,
usePredefineCalls: config.preload
addTryCatchRestartWrapper: config.preload
};

moduleBundlerOptions.bundleDefinition = getSapUiCoreBunDef(config.name, config.filters, config.preload);
Expand Down Expand Up @@ -390,7 +389,6 @@ export default async function({workspace, taskUtil, options: {skipBundles = [],
bundleDefinition: getBundleDefinition(libraryNamespace, excludes),
bundleOptions: {
optimize: true,
usePredefineCalls: true,
ignoreMissingModules: true
}
},
Expand All @@ -401,7 +399,6 @@ export default async function({workspace, taskUtil, options: {skipBundles = [],
bundleDefinition: getDesigntimeBundleDefinition(libraryNamespace),
bundleOptions: {
optimize: true,
usePredefineCalls: true,
ignoreMissingModules: true,
skipIfEmpty: true
}
Expand All @@ -413,7 +410,6 @@ export default async function({workspace, taskUtil, options: {skipBundles = [],
bundleDefinition: getSupportFilesBundleDefinition(libraryNamespace),
bundleOptions: {
optimize: false,
usePredefineCalls: true,
ignoreMissingModules: true,
skipIfEmpty: true
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading