From ce956c011ecc0fe3767896957d259f39ec7f6320 Mon Sep 17 00:00:00 2001 From: dhruvdutt Date: Tue, 17 Jul 2018 00:51:02 +0530 Subject: [PATCH] fix: default named import bug There are issues when we import TS compiled JS files into JS because TS compiles default exports to `default` named import/export which makes it not possible to import inside JS directly. Some of the ways to fix this is using .default in all calls or avoid using default export/import totally. Ref: https://basarat.gitbooks.io/typescript/docs/tips/defaultIsBad.html --- bin/prompt-command.js | 6 +++--- packages/utils/modify-config-helper.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/prompt-command.js b/bin/prompt-command.js index 8db70736521..71f697c9360 100644 --- a/bin/prompt-command.js +++ b/bin/prompt-command.js @@ -85,9 +85,9 @@ module.exports = function promptForInstallation(packages, ...args) { packages ); if (packages === "serve") { - return require(pathForCmd).serve(); + return require(pathForCmd).default.serve(); } - return require(pathForCmd)(...args); //eslint-disable-line + return require(pathForCmd).default(...args); //eslint-disable-line }) .catch(error => { console.error(error); @@ -105,6 +105,6 @@ module.exports = function promptForInstallation(packages, ...args) { } }); } else { - require(pathForCmd)(...args); // eslint-disable-line + require(pathForCmd).default(...args); // eslint-disable-line } }; diff --git a/packages/utils/modify-config-helper.ts b/packages/utils/modify-config-helper.ts index 0e1033e2b6f..3262d3488b0 100644 --- a/packages/utils/modify-config-helper.ts +++ b/packages/utils/modify-config-helper.ts @@ -3,7 +3,7 @@ import * as fs from "fs"; import * as logSymbols from "log-symbols"; import * as path from "path"; import * as yeoman from "yeoman-environment"; -import Generator from "yeoman-generator"; +import Generator = require("yeoman-generator"); import runTransform from "./scaffold"; import { IGenerator, IYeoman } from "./types/Yeoman";