Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

fix-next: add tsconfig.esm.json to TS projects #519

Merged
merged 3 commits into from
May 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions projectFilesManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,41 @@ function copyTemplate(templateName, destinationPath) {
}

function getProjectTemplates(projectDir) {
const templates = {}

const WEBPACK_CONFIG_NAME = "webpack.config.js";
const TSCONFIG_ESM_NAME = "tsconfig.esm.json";

let templates;
if (isAngular({projectDir})) {
templates["webpack.angular.js"] = WEBPACK_CONFIG_NAME;
templates["tsconfig.esm.json"] = "tsconfig.esm.json";
templates = getAngularTemplates(WEBPACK_CONFIG_NAME, TSCONFIG_ESM_NAME);
} else if (isTypeScript({projectDir})) {
templates["webpack.typescript.js"] = WEBPACK_CONFIG_NAME;
templates = getTypeScriptTemplates(WEBPACK_CONFIG_NAME, TSCONFIG_ESM_NAME);
} else {
templates["webpack.javascript.js"] = WEBPACK_CONFIG_NAME;
templates = getJavaScriptTemplates(WEBPACK_CONFIG_NAME);
}

return getFullTemplatesPath(projectDir, templates);
}

function getAngularTemplates(webpackConfigName, tsconfigName) {
return {
"webpack.angular.js": webpackConfigName,
[tsconfigName]: tsconfigName,
};
}

function getTypeScriptTemplates(webpackConfigName, tsconfigName) {
return {
"webpack.typescript.js": webpackConfigName,
[tsconfigName]: tsconfigName,
};
}

function getJavaScriptTemplates(webpackConfigName) {
return {
"webpack.javascript.js": webpackConfigName,
};
}

function getFullTemplatesPath(projectDir, templates) {
let updatedTemplates = {};

Expand Down
8 changes: 7 additions & 1 deletion templates/webpack.typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,13 @@ module.exports = env => {
]
},

{ test: /\.ts$/, use: "awesome-typescript-loader" }
{
test: /\.ts$/,
use: {
loader: "awesome-typescript-loader",
options: { configFileName: "tsconfig.esm.json" },
}
},
]
},
plugins: [
Expand Down