Skip to content

Commit

Permalink
always reemit assets for cache support
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Dec 17, 2018
1 parent db6eb51 commit cf5cd9d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
5 changes: 1 addition & 4 deletions src/loaders/node-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ module.exports = async function (content) {
const options = getOptions(this);

const pkgBase = getPackageBase(this.resourcePath) || path.dirname(id);
if (!options.assetNames[`sharedlibs:${pkgBase}`]) {
options.assetNames[`sharedlibs:${pkgBase}`] = true;
await sharedlibEmit(pkgBase, this.emitFile);
}
await sharedlibEmit(pkgBase, this.emitFile);

const name = getUniqueAssetName(id.substr(pkgBase.length + 1), id, options.assetNames);
this.emitFile(name, content);
Expand Down
17 changes: 4 additions & 13 deletions src/loaders/relocate-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,6 @@ module.exports = function (code) {
if (assetPath.endsWith('.js') || assetPath.endsWith('.mjs'))
return;

if (options.assets[assetPath])
return "__dirname + '/" + JSON.stringify(options.assets[assetPath]).slice(1, -1) + "'";

let outName = path.basename(assetPath);

if (assetPath.endsWith('.node')) {
Expand All @@ -238,14 +235,11 @@ module.exports = function (code) {
outName = assetPath.substr(pkgBase.length);
// If the asset is a ".node" binary, then glob for possible shared
// libraries that should also be included
if (!options.assetNames[`sharedlibs:${pkgBase}`]) {
options.assetNames[`sharedlibs:${pkgBase}`] = true;
assetEmissionPromises = assetEmissionPromises.then(sharedlibEmit(pkgBase, this.emitFile));
}
assetEmissionPromises = assetEmissionPromises.then(sharedlibEmit(pkgBase, this.emitFile));
}

const name = getUniqueAssetName(outName, assetPath, options.assetNames);
options.assets[assetPath] = name;
const name = options.assets[assetPath] ||
(options.assets[assetPath] = getUniqueAssetName(outName, assetPath, options.assetNames));

// console.log('Emitting ' + assetPath + ' for module ' + id);
assetEmissionPromises = assetEmissionPromises.then(async () => {
Expand All @@ -257,11 +251,8 @@ module.exports = function (code) {
return "__dirname + '/" + JSON.stringify(name).slice(1, -1) + "'";
};
const emitAssetDirectory = (assetDirPath) => {
if (options.assets[assetDirPath])
return "__dirname + '/" + JSON.stringify(options.assets[assetDirPath]).slice(1, -1) + "'";

const dirName = path.basename(assetDirPath);
const name = getUniqueAssetName(dirName, assetDirPath, options.assetNames);
const name = options.assets[assetDirPath] || (options.assets[assetDirPath] = getUniqueAssetName(dirName, assetDirPath, options.assetNames));
options.assets[assetDirPath] = name;

assetEmissionPromises = assetEmissionPromises.then(async () => {
Expand Down

0 comments on commit cf5cd9d

Please sign in to comment.