Skip to content

Commit

Permalink
Respect extension configuration in profile.js
Browse files Browse the repository at this point in the history
Fixes #1819.
  • Loading branch information
Alexander Gusev authored and novemberborn committed Sep 15, 2018
1 parent 9203448 commit 30a80b6
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ const Promise = require('bluebird');
const uniqueTempDir = require('unique-temp-dir');
const arrify = require('arrify');
const resolveCwd = require('resolve-cwd');
const escapeStringRegexp = require('escape-string-regexp');
const babelPipeline = require('./lib/babel-pipeline');
const RunStatus = require('./lib/run-status');
const VerboseReporter = require('./lib/reporters/verbose');
const loadConfig = require('./lib/load-config');
const normalizeExtensions = require('./lib/extensions');

function resolveModules(modules) {
return arrify(modules).map(name => {
Expand Down Expand Up @@ -70,12 +72,21 @@ if (cli.input.length === 0) {
const file = path.resolve(cli.input[0]);
const cacheDir = conf.cacheEnabled === false ? uniqueTempDir() : path.join(projectDir, 'node_modules', '.cache', 'ava');

const precompileFile = babelPipeline.build(process.cwd(), cacheDir, babelPipeline.validate(conf.babel), conf.compileEnhancements === true);
const precompiled = {};
if (precompileFile) {
precompiled[file] = precompileFile(file);
const babelConfig = babelPipeline.validate(conf.babel);
conf.extensions = normalizeExtensions(conf.extensions || [], babelConfig);

const _regexpFullExtensions = new RegExp(`\\.(${conf.extensions.full.map(ext => escapeStringRegexp(ext)).join('|')})$`);

const precompileFull = babelPipeline.build(process.cwd(), cacheDir, babelConfig, conf.compileEnhancements === true);

let precompileEnhancementsOnly = () => null;
if (conf.compileEnhancements) {
precompileEnhancementsOnly = babelPipeline.build(projectDir, cacheDir, null, conf.compileEnhancements);
}

const precompiled = {};
precompiled[file] = _regexpFullExtensions.test(file) ? precompileFull(file) : precompileEnhancementsOnly(file);

const opts = {
file,
projectDir,
Expand Down

0 comments on commit 30a80b6

Please sign in to comment.