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

fix: vue template crashes on start #997

Merged
merged 1 commit into from
Jul 22, 2019
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
2 changes: 1 addition & 1 deletion demo/AngularApp/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" && {
Expand Down
2 changes: 1 addition & 1 deletion demo/JavaScriptApp/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" && {
Expand Down
2 changes: 1 addition & 1 deletion demo/TypeScriptApp/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" && {
Expand Down
7 changes: 0 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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";
Expand Down
40 changes: 1 addition & 39 deletions index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { getConvertedExternals, getEntryPathRegExp } from './index';
const path = require("path");
import { getConvertedExternals } from './index';

describe('index', () => {
describe('getConvertedExternals', () => {
Expand Down Expand Up @@ -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);
});
});
});
2 changes: 1 addition & 1 deletion templates/webpack.angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" && {
Expand Down
1 change: 0 additions & 1 deletion templates/webpack.config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const nativeScriptDevWebpack = {
getAppPath: () => 'app',
getEntryModule: () => 'EntryModule',
getResolver: () => null,
getEntryPathRegExp: () => null,
getConvertedExternals: nsWebpackIndex.getConvertedExternals,
getSourceMapFilename: nsWebpackIndex.getSourceMapFilename
};
Expand Down
2 changes: 1 addition & 1 deletion templates/webpack.javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" && {
Expand Down
2 changes: 1 addition & 1 deletion templates/webpack.typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" && {
Expand Down
2 changes: 1 addition & 1 deletion templates/webpack.vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" && {
Expand Down