Skip to content

Commit

Permalink
Handle ignored files properly
Browse files Browse the repository at this point in the history
  • Loading branch information
loganfsmyth committed May 11, 2018
1 parent 4b1bcec commit 088f79c
Showing 1 changed file with 41 additions and 40 deletions.
81 changes: 41 additions & 40 deletions src/index.js
Expand Up @@ -72,46 +72,47 @@ async function loader(source, inputSourceMap) {
}

const config = babel.loadPartialConfig(programmaticOptions);

const options = config.options;

const {
cacheDirectory = null,
cacheIdentifier = JSON.stringify({
options,
"@babel/core": transform.version,
"@babel/loader": pkg.version,
}),
metadataSubscribers = [],
} = loaderOptions;

let result;
if (cacheDirectory) {
result = await cache({
source,
options,
transform,
cacheDirectory,
cacheIdentifier,
});
} else {
result = await transform(source, options);
}

// TODO: Babel should really provide the full list of config files that
// were used so that this can also handle files loaded with 'extends'.
if (typeof config.babelrc === "string") {
this.addDependency(config.babelrc);
}

if (result) {
const { code, map, metadata } = result;

metadataSubscribers.forEach(subscriber => {
subscribe(subscriber, metadata, this);
});

return [code, map];
if (config) {
const options = config.options;

const {
cacheDirectory = null,
cacheIdentifier = JSON.stringify({
options,
"@babel/core": transform.version,
"@babel/loader": pkg.version,
}),
metadataSubscribers = [],
} = loaderOptions;

let result;
if (cacheDirectory) {
result = await cache({
source,
options,
transform,
cacheDirectory,
cacheIdentifier,
});
} else {
result = await transform(source, options);
}

// TODO: Babel should really provide the full list of config files that
// were used so that this can also handle files loaded with 'extends'.
if (typeof config.babelrc === "string") {
this.addDependency(config.babelrc);
}

if (result) {
const { code, map, metadata } = result;

metadataSubscribers.forEach(subscriber => {
subscribe(subscriber, metadata, this);
});

return [code, map];
}
}

// If the file was ignored, pass through the original content.
Expand Down

0 comments on commit 088f79c

Please sign in to comment.