Skip to content

Commit

Permalink
chore: upgrade and fix eslint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Sep 27, 2022
1 parent 20577b6 commit fa0565a
Show file tree
Hide file tree
Showing 82 changed files with 1,289 additions and 1,281 deletions.
12 changes: 6 additions & 6 deletions src/AsyncPackage.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ AsyncPackage.prototype = {
},

addBundle: function(bundle) {
var bundleKey = bundle.getKey();
const bundleKey = bundle.getKey();

if (!this.bundlesByKey[bundleKey]) {
this.bundlesByKey[bundleKey] = true;
Expand All @@ -19,16 +19,16 @@ AsyncPackage.prototype = {
},

getMeta: function(context) {
var meta = {
const meta = {
css: [],
js: []
};

var bundles = this.bundles;
const bundles = this.bundles;

for (var i = 0, len = bundles.length; i < len; i++) {
var bundle = bundles[i];
var url;
for (let i = 0, len = bundles.length; i < len; i++) {
const bundle = bundles[i];
let url;
if (!bundle.hasContent() || !(url = bundle.getUrl(context))) {
// skip bundles without content or bundles that don't have a URL.
// TODO: Figure out what to do with inline dependencies that belong to an async bundle
Expand Down
12 changes: 6 additions & 6 deletions src/Bundle.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var contentTypes = require('./content-types');
const contentTypes = require('./content-types');

var Bundle = function(name) {
const Bundle = function(name) {
this.name = name;
this.dependencies = [];
this.slot = 'body';
Expand Down Expand Up @@ -55,7 +55,7 @@ Bundle.prototype = {
},

addDependency: function(dependency) {
var index = this.dependencies.length;
const index = this.dependencies.length;
this.dependencies.push(dependency);
return index;
},
Expand All @@ -77,7 +77,7 @@ Bundle.prototype = {
},

getHtmlAttributes: function() {
var attributes = {};
const attributes = {};
this.dependencies.forEach(function(dependency) {
if (typeof dependency.attributes === 'object') {
Object.keys(dependency.attributes).forEach(function(key) {
Expand All @@ -89,7 +89,7 @@ Bundle.prototype = {
},

getLabel: function() {
var contentType;
let contentType;

if (this.isJavaScript()) {
contentType = contentTypes.JS;
Expand Down Expand Up @@ -181,7 +181,7 @@ Bundle.prototype = {
},

toString: function() {
var details = [this.slot, this.contentType];
const details = [this.slot, this.contentType];
if (this.inlinePos) {
details.push('inlinePos=' + this.inlinePos);
}
Expand Down
6 changes: 3 additions & 3 deletions src/BundleConfig.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var ok = require('assert').ok;
var DependencyList = require('./DependencyList');
const ok = require('assert').ok;
const DependencyList = require('./DependencyList');

var BundleConfig = function(dirname, filename) {
const BundleConfig = function(dirname, filename) {
ok(dirname, '"dirname" is required');
ok(typeof dirname === 'string', '"dirname" is required');

Expand Down
61 changes: 31 additions & 30 deletions src/BundleMappings.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
var Bundle = require('./Bundle');
var InlinePos = require('./InlinePos');
var EventEmitter = require('events').EventEmitter;
var ok = require('assert').ok;
const Bundle = require('./Bundle');
const InlinePos = require('./InlinePos');
const EventEmitter = require('events').EventEmitter;
const ok = require('assert').ok;
const hasOwn = Object.prototype.hasOwnProperty;

function safeRelativePath(path) {
return path.replace(/[^A-Za-z0-9_.\-\/\\$@]/g, '_');
}

var BundleMappings = function(config, pageName) {
function BundleMappings(config, pageName) {
BundleMappings.$super.call(this);

ok(pageName == null || typeof pageName === 'string', 'pageName should be a String');
Expand Down Expand Up @@ -38,8 +39,8 @@ BundleMappings.prototype = {
},

getBundleMappingForDependency: function(dependency) {
var key = dependency.getKey();
var bundleMapping = this.dependencyToBundleMapping[key];
const key = dependency.getKey();
const bundleMapping = this.dependencyToBundleMapping[key];
if (bundleMapping) {
return bundleMapping;
} else if (this.parentBundleMappings) {
Expand All @@ -50,8 +51,8 @@ BundleMappings.prototype = {
},

getBundleForDependency: function(dependency) {
var key = dependency.getKey();
var bundleMapping = this.dependencyToBundleMapping[key];
const key = dependency.getKey();
const bundleMapping = this.dependencyToBundleMapping[key];
if (bundleMapping) {
return bundleMapping.bundle;
} else if (this.parentBundleMappings) {
Expand All @@ -62,21 +63,21 @@ BundleMappings.prototype = {
},

removeBundleMapping: function(bundleMapping) {
var dependency = bundleMapping.dependency;
const dependency = bundleMapping.dependency;
delete bundleMapping.bundleMappings.dependencyToBundleMapping[dependency.getKey()];
bundleMapping.bundle.removeDependencyByIndex(bundleMapping.index);
},

addDependencyToBundle: function(dependency, targetBundleName, dependencySlot, bundleConfig, lassoContext) {
ok(lassoContext, 'lassoContext expected');

var targetBundle;
let targetBundle;

if (dependency.isPackageDependency()) {
throw new Error('Illegal argument. Dependency cannot be a package dependency. Dependency: ' + dependency.toString());
}

var inlinePos = dependency.inline;
let inlinePos = dependency.inline;

if (inlinePos != null) {
if (inlinePos === 'true' || inlinePos === true || inlinePos === 'end') {
Expand All @@ -93,7 +94,7 @@ BundleMappings.prototype = {
}
}

var bundleKey = Bundle.getKey(dependencySlot, dependency.getContentType(), inlinePos, targetBundleName);
const bundleKey = Bundle.getKey(dependencySlot, dependency.getContentType(), inlinePos, targetBundleName);

targetBundle = this.bundlesByKey[bundleKey];

Expand All @@ -111,11 +112,11 @@ BundleMappings.prototype = {
this.bundlesByKey[bundleKey] = targetBundle;
}

var index = targetBundle.addDependency(dependency);
const index = targetBundle.addDependency(dependency);

var bundleMapping = {
const bundleMapping = {
// store the index of the dependency within the bundle
index: index,
index,

// store the bundle associated with the mapping
bundle: targetBundle,
Expand All @@ -124,14 +125,14 @@ BundleMappings.prototype = {
bundleMappings: this,

// store the dependency associated with the mapping
dependency: dependency
dependency
};

this.dependencyToBundleMapping[dependency.getKey()] = bundleMapping;

dependency.emit('addedToBundle', {
bundle: targetBundle,
lassoContext: lassoContext
lassoContext
});

return targetBundle;
Expand All @@ -144,9 +145,9 @@ BundleMappings.prototype = {
throw new Error('Illegal argument. Dependency cannot be a package dependency. Dependency: ' + dependency.toString());
}

var bundle;
var defaultBundleName = dependency.getDefaultBundleName(pageBundleName, lassoContext);
var flags = lassoContext.flags;
let bundle;
const defaultBundleName = dependency.getDefaultBundleName(pageBundleName, lassoContext);
const flags = lassoContext.flags;

if (this.inPlaceDeploymentEnabled && dependency.isInPlaceDeploymentAllowed()) {
// Create a bundle with a single dependency for each dependency
Expand Down Expand Up @@ -187,14 +188,14 @@ BundleMappings.prototype = {
// `${dependencyType}-${pageBundleName}` as the
// bundle name.

var targetBundle;
let targetBundle;

if (dependency.getUnbundledTarget) {
targetBundle = dependency.getUnbundledTarget(lassoContext);
}

if (!targetBundle && dependency.getSourceFile) {
let sourceFile = dependency.getSourceFile();
const sourceFile = dependency.getSourceFile();

if (sourceFile) {
targetBundle = lassoContext.getClientPath(sourceFile);
Expand All @@ -204,14 +205,14 @@ BundleMappings.prototype = {
if (targetBundle) {
targetBundle = safeRelativePath(targetBundle);

var prefix = pageBundleName.replace(/[\\\/]/g, '-');
let prefix = pageBundleName.replace(/[\\\/]/g, '-');

if (flags && !flags.isEmpty()) {
prefix += '-' + flags.getKey();
}

if (dependency.getUnbundledTargetPrefix) {
let unbundledTargetPrefix = dependency.getUnbundledTargetPrefix(lassoContext);
const unbundledTargetPrefix = dependency.getUnbundledTargetPrefix(lassoContext);
if (unbundledTargetPrefix) {
prefix += '/' + unbundledTargetPrefix;
}
Expand All @@ -220,7 +221,7 @@ BundleMappings.prototype = {
targetBundle = prefix + '/' + targetBundle;
}

var finalBundleName = defaultBundleName || targetBundle;
let finalBundleName = defaultBundleName || targetBundle;
if (!finalBundleName) {
finalBundleName = dependency.type + '-' + pageBundleName;

Expand Down Expand Up @@ -257,10 +258,10 @@ BundleMappings.prototype = {
},

toString: function() {
var lines = [];
for (var k in this.dependencyToBundleMapping) {
if (this.dependencyToBundleMapping.hasOwnProperty(k)) {
var targetBundle = this.dependencyToBundleMapping[k].bundle;
const lines = [];
for (const k in this.dependencyToBundleMapping) {
if (hasOwn.call(this.dependencyToBundleMapping, k)) {
const targetBundle = this.dependencyToBundleMapping[k].bundle;
lines.push(k + ' --> ' + targetBundle.toString());
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/BundleSetConfig.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var nextId = 0;
let nextId = 0;

function BundleSetConfig(name) {
this._id = nextId++;
Expand Down
Loading

0 comments on commit fa0565a

Please sign in to comment.