From 8d48f1d283af8c779b1ed2f61d0700c2abfedc29 Mon Sep 17 00:00:00 2001 From: Kristian Dimitrov Date: Fri, 19 Jul 2019 17:51:52 +0300 Subject: [PATCH] fix: vue template crashes on start --- demo/AngularApp/webpack.config.js | 2 +- demo/JavaScriptApp/webpack.config.js | 2 +- demo/TypeScriptApp/webpack.config.js | 2 +- index.js | 7 ----- index.spec.ts | 40 +--------------------------- templates/webpack.angular.js | 2 +- templates/webpack.config.spec.ts | 1 - templates/webpack.javascript.js | 2 +- templates/webpack.typescript.js | 2 +- templates/webpack.vue.js | 2 +- 10 files changed, 8 insertions(+), 54 deletions(-) diff --git a/demo/AngularApp/webpack.config.js b/demo/AngularApp/webpack.config.js index 9ad1ba8f..8137073f 100644 --- a/demo/AngularApp/webpack.config.js +++ b/demo/AngularApp/webpack.config.js @@ -198,7 +198,7 @@ module.exports = env => { module: { rules: [ { - test: nsWebpack.getEntryPathRegExp(appFullPath, entryPath), + include: join(appFullPath, entryPath), use: [ // Require all Android app components platform === "android" && { diff --git a/demo/JavaScriptApp/webpack.config.js b/demo/JavaScriptApp/webpack.config.js index ddcf17ea..ec4ea0b5 100644 --- a/demo/JavaScriptApp/webpack.config.js +++ b/demo/JavaScriptApp/webpack.config.js @@ -159,7 +159,7 @@ module.exports = env => { module: { rules: [ { - test: nsWebpack.getEntryPathRegExp(appFullPath, entryPath), + include: join(appFullPath, entryPath), use: [ // Require all Android app components platform === "android" && { diff --git a/demo/TypeScriptApp/webpack.config.js b/demo/TypeScriptApp/webpack.config.js index 9bc21ca6..64ad184c 100644 --- a/demo/TypeScriptApp/webpack.config.js +++ b/demo/TypeScriptApp/webpack.config.js @@ -165,7 +165,7 @@ module.exports = env => { module: { rules: [ { - test: nsWebpack.getEntryPathRegExp(appFullPath, entryPath), + include: join(appFullPath, entryPath), use: [ // Require all Android app components platform === "android" && { diff --git a/index.js b/index.js index 3d24db39..74afd066 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,5 @@ const path = require("path"); const { existsSync } = require("fs"); -const escapeRegExp = require("escape-string-regexp"); const { ANDROID_APP_PATH } = require("./androidProjectHelpers"); const { getPackageJson, @@ -61,12 +60,6 @@ exports.getAppPath = (platform, projectDir) => { } }; -exports.getEntryPathRegExp = (appFullPath, entryModule) => { - const entryModuleFullPath = path.join(appFullPath, entryModule); - const escapedPath = escapeRegExp(entryModuleFullPath); - return new RegExp(escapedPath); -} - exports.getSourceMapFilename = (hiddenSourceMap, appFolderPath, outputPath) => { const appFolderRelativePath = path.join(path.relative(outputPath, appFolderPath)); let sourceMapFilename = "[file].map"; diff --git a/index.spec.ts b/index.spec.ts index d97dc20d..4e5471bb 100644 --- a/index.spec.ts +++ b/index.spec.ts @@ -1,5 +1,4 @@ -import { getConvertedExternals, getEntryPathRegExp } from './index'; -const path = require("path"); +import { getConvertedExternals } from './index'; describe('index', () => { describe('getConvertedExternals', () => { @@ -52,41 +51,4 @@ describe('index', () => { }); }); }); - - describe('getEntryPathRegExp', () => { - const originalPathJoin = path.join; - const entryModule = "index.js"; - - afterEach(() => { - path.join = originalPathJoin; - }); - - it('returns RegExp that works with Windows paths', () => { - const appPath = "D:\\Work\\app1\\app"; - path.join = path.win32.join; - const regExp = getEntryPathRegExp(appPath, entryModule); - expect(!!regExp.exec(`${appPath}\\${entryModule}`)).toBe(true); - }); - - it('returns RegExp that works with POSIX paths', () => { - const appPath = "/usr/local/lib/app1/app"; - path.join = path.posix.join; - const regExp = getEntryPathRegExp(appPath, entryModule); - expect(!!regExp.exec(`${appPath}/${entryModule}`)).toBe(true); - }); - - it('returns RegExp that works with Windows paths with special symbol in path', () => { - const appPath = "D:\\Work\\app1\\app (2)"; - path.join = path.win32.join; - const regExp = getEntryPathRegExp(appPath, entryModule); - expect(!!regExp.exec(`${appPath}\\${entryModule}`)).toBe(true); - }); - - it('returns RegExp that works with POSIX paths with special symbol in path', () => { - const appPath = "/usr/local/lib/app1/app (2)"; - path.join = path.posix.join; - const regExp = getEntryPathRegExp(appPath, entryModule); - expect(!!regExp.exec(`${appPath}/${entryModule}`)).toBe(true); - }); - }); }); diff --git a/templates/webpack.angular.js b/templates/webpack.angular.js index d7cd1e78..fa623eee 100644 --- a/templates/webpack.angular.js +++ b/templates/webpack.angular.js @@ -197,7 +197,7 @@ module.exports = env => { module: { rules: [ { - test: nsWebpack.getEntryPathRegExp(appFullPath, entryPath), + include: join(appFullPath, entryPath), use: [ // Require all Android app components platform === "android" && { diff --git a/templates/webpack.config.spec.ts b/templates/webpack.config.spec.ts index eced35fc..024461bd 100644 --- a/templates/webpack.config.spec.ts +++ b/templates/webpack.config.spec.ts @@ -31,7 +31,6 @@ const nativeScriptDevWebpack = { getAppPath: () => 'app', getEntryModule: () => 'EntryModule', getResolver: () => null, - getEntryPathRegExp: () => null, getConvertedExternals: nsWebpackIndex.getConvertedExternals, getSourceMapFilename: nsWebpackIndex.getSourceMapFilename }; diff --git a/templates/webpack.javascript.js b/templates/webpack.javascript.js index 18d28bc7..f9add996 100644 --- a/templates/webpack.javascript.js +++ b/templates/webpack.javascript.js @@ -161,7 +161,7 @@ module.exports = env => { module: { rules: [ { - test: nsWebpack.getEntryPathRegExp(appFullPath, entryPath), + include: join(appFullPath, entryPath), use: [ // Require all Android app components platform === "android" && { diff --git a/templates/webpack.typescript.js b/templates/webpack.typescript.js index a6bda652..9e0a3e84 100644 --- a/templates/webpack.typescript.js +++ b/templates/webpack.typescript.js @@ -164,7 +164,7 @@ module.exports = env => { module: { rules: [ { - test: nsWebpack.getEntryPathRegExp(appFullPath, entryPath), + include: join(appFullPath, entryPath), use: [ // Require all Android app components platform === "android" && { diff --git a/templates/webpack.vue.js b/templates/webpack.vue.js index b0539c0e..61068c7f 100644 --- a/templates/webpack.vue.js +++ b/templates/webpack.vue.js @@ -170,7 +170,7 @@ module.exports = env => { }, module: { rules: [{ - test: nsWebpack.getEntryPathRegExp(appFullPath, entryPath + ".(js|ts)"), + include: [join(appFullPath, entryPath + ".js"), join(appFullPath, entryPath + ".ts")], use: [ // Require all Android app components platform === "android" && {