Skip to content

Commit

Permalink
fix: do not load browser.json files by default
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Mar 11, 2020
1 parent 701b1e4 commit 0fa09f5
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions src/loader/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,27 +154,31 @@ export default function(source: string): string {

if (meta.deps) {
dependencies = dependencies.concat(
meta.deps.map(dependency => {
if (!dependency.code) {
if (
supportsBrowserJSON &&
dependency.startsWith(browserJSONPrefix)
) {
dependency = dependency.slice(browserJSONPrefix.length);
meta.deps
.map(dependency => {
if (!dependency.code) {
if (dependency.startsWith(browserJSONPrefix)) {
if (supportsBrowserJSON) {
dependency = dependency.slice(browserJSONPrefix.length);
} else {
return ""; // Do not load browser.json dependencies by default.
}
}

// external file, just require it
return loadStr(dependency);
} else {
// inline content, we'll create a virtual dependency.
const virtualPath = path.resolve(
path.dirname(this.resourcePath),
dependency.virtualPath
);
const virtualModules = getVirtualModules(this._compiler);
virtualModules.writeModule(virtualPath, dependency.code);
return loadStr(dependency.virtualPath);
}
// external file, just require it
return loadStr(dependency);
} else {
// inline content, we'll create a virtual dependency.
const virtualPath = path.resolve(
path.dirname(this.resourcePath),
dependency.virtualPath
);
const virtualModules = getVirtualModules(this._compiler);
virtualModules.writeModule(virtualPath, dependency.code);
return loadStr(dependency.virtualPath);
}
})
})
.filter(Boolean)
);
}

Expand Down

0 comments on commit 0fa09f5

Please sign in to comment.