|
1 | 1 | import { transform } from 'babel-core';
|
2 |
| -import resolveRc from 'babel-core/lib/babel/tools/resolve-rc'; |
3 |
| -import * as babelUtil from 'babel-core/lib/babel/util'; |
4 | 2 | import glob from 'glob';
|
5 | 3 | import fs from 'fs';
|
6 | 4 | import path from 'path';
|
7 | 5 | import outputFileSync from 'output-file-sync';
|
8 | 6 |
|
9 | 7 | export function buildContent(content, filename, destination, babelOptions={}) {
|
10 |
| - const result = transform(content, resolveRc(filename, babelOptions)); |
| 8 | + babelOptions.filename = filename; |
| 9 | + const result = transform(content, babelOptions); |
11 | 10 | outputFileSync(destination, result.code, {encoding: 'utf8'});
|
12 | 11 | }
|
13 | 12 |
|
14 | 13 | export function buildFile(filename, destination, babelOptions={}) {
|
15 | 14 | const content = fs.readFileSync(filename, {encoding: 'utf8'});
|
16 |
| - if(babelUtil.canCompile(filename)) { |
17 |
| - // Get file basename without the extension (in case not .js) |
18 |
| - let outputName = path.basename(filename, path.extname(filename)); |
19 |
| - // append the file basename with extension .js |
20 |
| - let outputPath = path.join(destination, outputName + '.js'); |
| 15 | + // We only have .js files that we need to build |
| 16 | + if(path.extname(filename) === '.js') { |
| 17 | + const outputPath = path.join(destination, path.basename(filename)); |
21 | 18 | // console.log('%s => %s', filename, outputPath);
|
22 | 19 | buildContent(content, filename, outputPath, babelOptions);
|
23 | 20 | }
|
|
0 commit comments