Skip to content

Commit

Permalink
🔧 Don't use babel config file (#1)
Browse files Browse the repository at this point in the history
* ⬆️ update deps

* 🔧 dont use babel config

* 📦 publish
  • Loading branch information
9at8 authored Jul 27, 2019
1 parent 2dc370a commit e54ef2b
Show file tree
Hide file tree
Showing 7 changed files with 947 additions and 1,533 deletions.
2 changes: 1 addition & 1 deletion dist/converter.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as babel from "@babel/core";
import * as babel from '@babel/core';
export declare const babelOptions: (rootDir: string) => babel.TransformOptions;
export default function convert(files: string[], rootDir: string): Promise<{
successFiles: string[];
Expand Down
3 changes: 2 additions & 1 deletion dist/converter.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/converter.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
"typescript": ">=3.0"
},
"dependencies": {
"@babel/plugin-syntax-dynamic-import": "7.2.0",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"babel-plugin-flow-to-typescript": "git+https://github.com/rgoldfinger-quizlet/babel-plugin-flow-to-typescript.git#facfeb4f65e270d3635891b870886b971946ebb8",
"@babel/traverse": "7.2.3",
"@babel/types": "7.2.2",
"@babel/traverse": "^7.2.3",
"@babel/types": "^7.2.2",
"lodash": "^4.17.11",
"prettier": "^1.16.4",
"recast": "^0.17.5",
Expand All @@ -56,12 +56,12 @@
"@types/prettier": "^1.16.1",
"@types/react": "^16.8.17",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^23.6.0",
"babel-jest": "^24.8.0",
"babel-plugin-tester": "^5.0.0",
"jest": "^23.6.0",
"jest": "^24.8.0",
"react": "^16.8.6",
"regenerator-runtime": "^0.13.1",
"ts-jest": "^23.10.5",
"ts-jest": "^24.0.2",
"ts-node": "^8.0.3",
"tslint": "^5.9.1",
"typescript": "^3.4.5"
Expand Down
19 changes: 10 additions & 9 deletions src/converter.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as babel from "@babel/core";
import * as babel from '@babel/core';
// @ts-ignore
import dynamicImport from "@babel/plugin-syntax-dynamic-import";
import recast from "recast";
import { writeFileSync } from "fs";
import plugin from "babel-plugin-flow-to-typescript";
import { asyncForEach } from "./util";
import prettierFormat from "./prettierFormat";
import { stripComments } from "./stripComments";
import dynamicImport from '@babel/plugin-syntax-dynamic-import';
import recast from 'recast';
import { writeFileSync } from 'fs';
import plugin from 'babel-plugin-flow-to-typescript';
import { asyncForEach } from './util';
import prettierFormat from './prettierFormat';
import { stripComments } from './stripComments';

function recastParse(
code: string,
Expand Down Expand Up @@ -38,6 +38,7 @@ const recastPlugin = function(rootDir: string) {
};

export const babelOptions = (rootDir: string): babel.TransformOptions => ({
configFile: false,
plugins: [recastPlugin(rootDir), plugin, dynamicImport]
});

Expand All @@ -50,7 +51,7 @@ export default async function convert(files: string[], rootDir: string) {
let res;
try {
res = await babel.transformFileAsync(path, babelOptions(rootDir));
res!.code = stripComments(res!.code!, ["// @flow", "// @noflow"])[0];
res!.code = stripComments(res!.code!, ['// @flow', '// @noflow'])[0];
} catch (err) {
console.log(err);
errorFiles.push(path);
Expand Down
10 changes: 4 additions & 6 deletions test/recast/recastConverter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ describe("recast converter", () => {
title: "preserves comments above imports",
code: `// @flow\nimport * as React from "react";`,
output: `// @flow
import * as React from "react";
`
import * as React from "react";`
},
{
title: "preserves comments within typedefs",
Expand All @@ -32,11 +31,10 @@ import * as React from "react";
verticalAlignWithoutScroll?: "top" | "center",
};`,
output: `type Props = {
children?: React.Node;
children?: React.Node,
// The vertical alignment of the content before it starts to scroll
verticalAlignWithoutScroll?: "top" | "center";
};
`
verticalAlignWithoutScroll?: "top" | "center"
};`
}
]);
});
Loading

0 comments on commit e54ef2b

Please sign in to comment.