Skip to content

Commit

Permalink
fix: default named import bug
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dhruvdutt committed Jul 16, 2018
1 parent 971b31a commit ce956c0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions bin/prompt-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -105,6 +105,6 @@ module.exports = function promptForInstallation(packages, ...args) {
}
});
} else {
require(pathForCmd)(...args); // eslint-disable-line
require(pathForCmd).default(...args); // eslint-disable-line
}
};
2 changes: 1 addition & 1 deletion packages/utils/modify-config-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit ce956c0

Please sign in to comment.