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

Commit

Permalink
fix: avoid getting js template in a ts project as we don't have a…
Browse files Browse the repository at this point in the history
… `typescript` dependency in the templates anymore
  • Loading branch information
DimitarTachev committed Nov 20, 2018
1 parent a6da3d6 commit 5fa8c73
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 282 deletions.
12 changes: 2 additions & 10 deletions projectFilesManager.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const path = require("path");
const fs = require("fs");

const { isTypeScript, isAngular, isVue } = require("./projectHelpers");
const { isAngular, isVue } = require("./projectHelpers");

function addProjectFiles(projectDir) {
const projectTemplates = getProjectTemplates(projectDir);
Expand Down Expand Up @@ -65,10 +65,8 @@ function getProjectTemplates(projectDir) {
templates = getAngularTemplates(WEBPACK_CONFIG_NAME, TSCONFIG_TNS_NAME);
} else if (isVue({ projectDir })) {
templates = getVueTemplates(WEBPACK_CONFIG_NAME);
} else if (isTypeScript({ projectDir })) {
templates = getTypeScriptTemplates(WEBPACK_CONFIG_NAME, TSCONFIG_TNS_NAME);
} else {
templates = getJavaScriptTemplates(WEBPACK_CONFIG_NAME);
templates = getTypeScriptTemplates(WEBPACK_CONFIG_NAME, TSCONFIG_TNS_NAME);
}

return getFullTemplatesPath(projectDir, templates);
Expand All @@ -94,12 +92,6 @@ function getVueTemplates(webpackConfigName) {
};
}

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

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

Expand Down
13 changes: 0 additions & 13 deletions projectHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,6 @@ const PROJECT_DATA_GETTERS = {
appResourcesPath: "getAppResourcesRelativeDirectoryPath",
};

const isTypeScript = ({ projectDir, packageJson } = {}) => {
packageJson = packageJson || getPackageJson(projectDir);

return (
packageJson.dependencies &&
packageJson.dependencies.hasOwnProperty("typescript")
) || (
packageJson.devDependencies &&
packageJson.devDependencies.hasOwnProperty("typescript")
) || isAngular({ packageJson });
};

const isAngular = ({ projectDir, packageJson } = {}) => {
packageJson = packageJson || getPackageJson(projectDir);

Expand Down Expand Up @@ -92,7 +80,6 @@ module.exports = {
isIos,
isAngular,
isVue,
isTypeScript,
writePackageJson,
convertSlashesInPath
};
256 changes: 0 additions & 256 deletions templates/webpack.javascript.js

This file was deleted.

6 changes: 3 additions & 3 deletions templates/webpack.typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = env => {
const appResourcesFullPath = resolve(projectRoot, appResourcesPath);

const entryModule = nsWebpack.getEntryModule(appFullPath);
const entryPath = `.${sep}${entryModule}.ts`;
const entryPath = `.${sep}${entryModule}`;

const config = {
mode: uglify ? "production" : "development",
Expand Down Expand Up @@ -140,7 +140,7 @@ module.exports = env => {
module: {
rules: [
{
test: new RegExp(entryPath),
test: new RegExp(entryPath + "\.[jt]s"),
use: [
// Require all Android app components
platform === "android" && {
Expand All @@ -158,7 +158,7 @@ module.exports = env => {
},

{
test: /-page\.ts$/,
test: /-page\.[jt]s$/,
use: "nativescript-dev-webpack/script-hot-loader"
},

Expand Down

0 comments on commit 5fa8c73

Please sign in to comment.