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

Commit c3ed607

Browse files
authored
fix: vue template crashes on start (#997)
1 parent 5cadf73 commit c3ed607

10 files changed

+8
-54
lines changed

Diff for: demo/AngularApp/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ module.exports = env => {
198198
module: {
199199
rules: [
200200
{
201-
test: nsWebpack.getEntryPathRegExp(appFullPath, entryPath),
201+
include: join(appFullPath, entryPath),
202202
use: [
203203
// Require all Android app components
204204
platform === "android" && {

Diff for: demo/JavaScriptApp/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ module.exports = env => {
159159
module: {
160160
rules: [
161161
{
162-
test: nsWebpack.getEntryPathRegExp(appFullPath, entryPath),
162+
include: join(appFullPath, entryPath),
163163
use: [
164164
// Require all Android app components
165165
platform === "android" && {

Diff for: demo/TypeScriptApp/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ module.exports = env => {
165165
module: {
166166
rules: [
167167
{
168-
test: nsWebpack.getEntryPathRegExp(appFullPath, entryPath),
168+
include: join(appFullPath, entryPath),
169169
use: [
170170
// Require all Android app components
171171
platform === "android" && {

Diff for: index.js

-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const path = require("path");
22
const { existsSync } = require("fs");
3-
const escapeRegExp = require("escape-string-regexp");
43
const { ANDROID_APP_PATH } = require("./androidProjectHelpers");
54
const {
65
getPackageJson,
@@ -61,12 +60,6 @@ exports.getAppPath = (platform, projectDir) => {
6160
}
6261
};
6362

64-
exports.getEntryPathRegExp = (appFullPath, entryModule) => {
65-
const entryModuleFullPath = path.join(appFullPath, entryModule);
66-
const escapedPath = escapeRegExp(entryModuleFullPath);
67-
return new RegExp(escapedPath);
68-
}
69-
7063
exports.getSourceMapFilename = (hiddenSourceMap, appFolderPath, outputPath) => {
7164
const appFolderRelativePath = path.join(path.relative(outputPath, appFolderPath));
7265
let sourceMapFilename = "[file].map";

Diff for: index.spec.ts

+1-39
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { getConvertedExternals, getEntryPathRegExp } from './index';
2-
const path = require("path");
1+
import { getConvertedExternals } from './index';
32

43
describe('index', () => {
54
describe('getConvertedExternals', () => {
@@ -52,41 +51,4 @@ describe('index', () => {
5251
});
5352
});
5453
});
55-
56-
describe('getEntryPathRegExp', () => {
57-
const originalPathJoin = path.join;
58-
const entryModule = "index.js";
59-
60-
afterEach(() => {
61-
path.join = originalPathJoin;
62-
});
63-
64-
it('returns RegExp that works with Windows paths', () => {
65-
const appPath = "D:\\Work\\app1\\app";
66-
path.join = path.win32.join;
67-
const regExp = getEntryPathRegExp(appPath, entryModule);
68-
expect(!!regExp.exec(`${appPath}\\${entryModule}`)).toBe(true);
69-
});
70-
71-
it('returns RegExp that works with POSIX paths', () => {
72-
const appPath = "/usr/local/lib/app1/app";
73-
path.join = path.posix.join;
74-
const regExp = getEntryPathRegExp(appPath, entryModule);
75-
expect(!!regExp.exec(`${appPath}/${entryModule}`)).toBe(true);
76-
});
77-
78-
it('returns RegExp that works with Windows paths with special symbol in path', () => {
79-
const appPath = "D:\\Work\\app1\\app (2)";
80-
path.join = path.win32.join;
81-
const regExp = getEntryPathRegExp(appPath, entryModule);
82-
expect(!!regExp.exec(`${appPath}\\${entryModule}`)).toBe(true);
83-
});
84-
85-
it('returns RegExp that works with POSIX paths with special symbol in path', () => {
86-
const appPath = "/usr/local/lib/app1/app (2)";
87-
path.join = path.posix.join;
88-
const regExp = getEntryPathRegExp(appPath, entryModule);
89-
expect(!!regExp.exec(`${appPath}/${entryModule}`)).toBe(true);
90-
});
91-
});
9254
});

Diff for: templates/webpack.angular.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ module.exports = env => {
197197
module: {
198198
rules: [
199199
{
200-
test: nsWebpack.getEntryPathRegExp(appFullPath, entryPath),
200+
include: join(appFullPath, entryPath),
201201
use: [
202202
// Require all Android app components
203203
platform === "android" && {

Diff for: templates/webpack.config.spec.ts

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ const nativeScriptDevWebpack = {
3131
getAppPath: () => 'app',
3232
getEntryModule: () => 'EntryModule',
3333
getResolver: () => null,
34-
getEntryPathRegExp: () => null,
3534
getConvertedExternals: nsWebpackIndex.getConvertedExternals,
3635
getSourceMapFilename: nsWebpackIndex.getSourceMapFilename
3736
};

Diff for: templates/webpack.javascript.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ module.exports = env => {
161161
module: {
162162
rules: [
163163
{
164-
test: nsWebpack.getEntryPathRegExp(appFullPath, entryPath),
164+
include: join(appFullPath, entryPath),
165165
use: [
166166
// Require all Android app components
167167
platform === "android" && {

Diff for: templates/webpack.typescript.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ module.exports = env => {
164164
module: {
165165
rules: [
166166
{
167-
test: nsWebpack.getEntryPathRegExp(appFullPath, entryPath),
167+
include: join(appFullPath, entryPath),
168168
use: [
169169
// Require all Android app components
170170
platform === "android" && {

Diff for: templates/webpack.vue.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ module.exports = env => {
170170
},
171171
module: {
172172
rules: [{
173-
test: nsWebpack.getEntryPathRegExp(appFullPath, entryPath + ".(js|ts)"),
173+
include: [join(appFullPath, entryPath + ".js"), join(appFullPath, entryPath + ".ts")],
174174
use: [
175175
// Require all Android app components
176176
platform === "android" && {

0 commit comments

Comments
 (0)