Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function (source, inputSourceMap) {
var _this = this;
// Handle filenames (#106)
var webpackRemainingChain = loaderUtils.getRemainingRequest(this).split("!");
var filename = webpackRemainingChain[webpackRemainingChain.length - 1];
// Handle options
var loaderOptions = loaderUtils.getOptions(this) || {};
var fileSystem = this.fs ? this.fs : fs;
var babelrcPath = null;
if (loaderOptions.babelrc !== false) {
babelrcPath = typeof loaderOptions.babelrc === "string" && exists(fileSystem, loaderOptions.babelrc) ? loaderOptions.babelrc : resolveRc(fileSystem, path.dirname(filename));
}
if (babelrcPath) {
this.addDependency(babelrcPath);
}
var defaultOptions = {
metadataSubscribers: [],
if (map.sources) {
map.sources = map.sources.map(function (source) {
return source.replace(/\\/g, '/')
})
map.sourceRoot = ''
}
}
} else {
// Some loaders (example `"postcss-loader": "1.x.x"`) always generates source map, we should remove it
map = null
}
processCss(content, map, {
mode: moduleMode ? 'local' : 'global',
from: loaderUtils.getRemainingRequest(this).split('!').pop(),
to: loaderUtils.getCurrentRequest(this).split('!').pop(),
query: query,
resolve: resolve,
minimize: this.minimize,
loaderContext: this,
sourceMap: sourceMap
}, function (err, result) {
if (err) return callback(err)
var cssAsString = JSON.stringify(result.source)
// for importing CSS
var importUrlPrefix = getImportPrefix(this, query)
var alreadyImported = {}
var importJs = result.importItems.filter(function (imp) {
? transpileCached({
...transpileOptions,
cacheDirectoryPath: optionsScopedCachePath,
fileContents
})
: ts.transpileModule(fileContents, transpileOptions);
if (diagnostics && diagnostics.length) {
this.emitError(new Error(ts.formatDiagnostics(diagnostics, formatDiagnosticsHost)));
}
if (sourceMapText) {
const rawSourceMap = JSON.parse(sourceMapText) as import('source-map').RawSourceMap;
if (rawSourceMap.sources.length === 1) {
// ensure source maps point to the correct target in a loader chain
rawSourceMap.sources[0] = getRemainingRequest(this);
}
// find/remove inline comment linking to sourcemap
const sourceMappingIdx = outputText.lastIndexOf(externalSourceMapPrefix);
this.callback(null, sourceMappingIdx === -1 ? outputText : outputText.slice(0, sourceMappingIdx), rawSourceMap);
} else {
this.callback(null, outputText);
}
};
function getRawRequest ({ resource, loaderIndex, loaders }, excludedPreLoaders = /eslint-loader/) {
return loaderUtils.getRemainingRequest({
resource: resource,
loaderIndex: loaderIndex,
loaders: loaders.filter(loader => !excludedPreLoaders.test(loader.path))
})
}
function GroupCssMediaQueriesLoader(inputSource, prevMap, meta) {
const options = getOptions(this) || {};
const sourceMap =
options.sourceMap === undefined
? this.sourceMap
: Boolean(options.sourceMap);
const callback = this.async();
pipeline
.process(inputSource, {
from: getRemainingRequest(this)
.split("!")
.pop(),
to: getCurrentRequest(this)
.split("!")
.pop(),
map: sourceMap
? {
prev: prevMap,
sourcesContent: true,
inline: false,
annotation: false
}
: null
})
.then(result => {
callback(null, result.css, result.map && result.map.toJSON(), meta);
function getRawRequest (
{ resource, loaderIndex, loaders },
excludedPreLoaders = /eslint-loader/
) {
return loaderUtils.getRemainingRequest({
resource: resource,
loaderIndex: loaderIndex,
loaders: loaders.filter(loader => !excludedPreLoaders.test(loader.path))
})
}
function defaultOptions(context, map){
var options = {}
options.from = loaderUtils.getRemainingRequest(context)
options.to = loaderUtils.getRemainingRequest(context)
if (context.sourceMap) {
options.map = {
inline: false,
annotation: false,
prev: map
}
}
options.compress = context.minimize
return options
}