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

Commit 8922c96

Browse files
authored
fix-next: add tsconfig.esm.json to TS projects (#519)
1 parent 8ec3b8e commit 8922c96

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

Diff for: projectFilesManager.js

+26-6
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,41 @@ function copyTemplate(templateName, destinationPath) {
5757
}
5858

5959
function getProjectTemplates(projectDir) {
60-
const templates = {}
61-
6260
const WEBPACK_CONFIG_NAME = "webpack.config.js";
61+
const TSCONFIG_ESM_NAME = "tsconfig.esm.json";
62+
63+
let templates;
6364
if (isAngular({projectDir})) {
64-
templates["webpack.angular.js"] = WEBPACK_CONFIG_NAME;
65-
templates["tsconfig.esm.json"] = "tsconfig.esm.json";
65+
templates = getAngularTemplates(WEBPACK_CONFIG_NAME, TSCONFIG_ESM_NAME);
6666
} else if (isTypeScript({projectDir})) {
67-
templates["webpack.typescript.js"] = WEBPACK_CONFIG_NAME;
67+
templates = getTypeScriptTemplates(WEBPACK_CONFIG_NAME, TSCONFIG_ESM_NAME);
6868
} else {
69-
templates["webpack.javascript.js"] = WEBPACK_CONFIG_NAME;
69+
templates = getJavaScriptTemplates(WEBPACK_CONFIG_NAME);
7070
}
7171

7272
return getFullTemplatesPath(projectDir, templates);
7373
}
7474

75+
function getAngularTemplates(webpackConfigName, tsconfigName) {
76+
return {
77+
"webpack.angular.js": webpackConfigName,
78+
[tsconfigName]: tsconfigName,
79+
};
80+
}
81+
82+
function getTypeScriptTemplates(webpackConfigName, tsconfigName) {
83+
return {
84+
"webpack.typescript.js": webpackConfigName,
85+
[tsconfigName]: tsconfigName,
86+
};
87+
}
88+
89+
function getJavaScriptTemplates(webpackConfigName) {
90+
return {
91+
"webpack.javascript.js": webpackConfigName,
92+
};
93+
}
94+
7595
function getFullTemplatesPath(projectDir, templates) {
7696
let updatedTemplates = {};
7797

Diff for: templates/webpack.typescript.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,13 @@ module.exports = env => {
166166
]
167167
},
168168

169-
{ test: /\.ts$/, use: "awesome-typescript-loader" }
169+
{
170+
test: /\.ts$/,
171+
use: {
172+
loader: "awesome-typescript-loader",
173+
options: { configFileName: "tsconfig.esm.json" },
174+
}
175+
},
170176
]
171177
},
172178
plugins: [

0 commit comments

Comments
 (0)