Skip to content

Commit

Permalink
[BREAKING] Bundling: Remove option 'usePredefineCalls'
Browse files Browse the repository at this point in the history
  • Loading branch information
flovogt committed May 21, 2024
1 parent 2c09a11 commit b335c3b
Show file tree
Hide file tree
Showing 89 changed files with 212 additions and 412 deletions.
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

0 comments on commit b335c3b

Please sign in to comment.