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

chore: update deps #1141

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

First of all, thank you for taking the time to contribute!

Before starting, make yourself familiar with the `nativescript-dev-webpack`'s [documentation](http://docs.nativescript.org/best-practices/bundling-with-webpack) and the official [NativeScript Code Of Conduct]( https://github.com/NativeScript/codeofconduct).
Before starting, make yourself familiar with the `@nativescript/webpack`'s [documentation](http://docs.nativescript.org/best-practices/bundling-with-webpack) and the official [NativeScript Code Of Conduct]( https://github.com/NativeScript/codeofconduct).

## Project Structure

Expand Down Expand Up @@ -67,7 +67,7 @@ NOTE: There are three test apps in the repository, located in the `/demo` direct
cd demo/AngularApp
```

2. Install your local copy of the `nativescript-dev-webpack` plugin.
2. Install your local copy of the `@nativescript/webpack` plugin.
```bash
npm run setup
```
Expand Down
12 changes: 6 additions & 6 deletions PULL_REQUEST_TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ This document describes comment messages available to execute tests on pull requ
|Comment |Commit Status Context|Description|
|:----------------------:|:-------------------:|:---------:|
|`run ci` | |Run all below.|
|`js`|ci/jenkins/webpack-js|Pack the *nativescript-dev-webpack* plugin and bundle the [template-hello-world](https://github.com/NativeScript/template-hello-world) template app. |
|`ts`|ci/jenkins/webpack-ts|Pack the *nativescript-dev-webpack* plugin and bundle the [template-hello-world-ts](https://github.com/NativeScript/template-hello-world-ts) template app.|
|`ng`|ci/jenkins/webpack-ng|Pack the *nativescript-dev-webpack* plugin and bundle the [template-hello-world-ng](https://github.com/NativeScript/template-hello-world-ng) template app.|
|`groceries`|ci/jenkins/webpack-groceries|Pack the *nativescript-dev-webpack* plugin and bundle the [Groceries](https://github.com/NativeScript/sample-Groceries) app. |
|`sdk`|ci/jenkins/webpack-sdk|Pack the *nativescript-dev-webpack* plugin and bundle the [SDK](https://github.com/NativeScript/nativescript-sdk-examples-ng) app. |
|`testsappng`|ci/jenkins/webpack-testsappng|Pack the *nativescript-dev-webpack* plugin and bundle the [tests-app-ng](https://github.com/NativeScript/tests-app-ng) app. |
|`js`|ci/jenkins/webpack-js|Pack the *@nativescript/webpack* plugin and bundle the [template-hello-world](https://github.com/NativeScript/template-hello-world) template app. |
|`ts`|ci/jenkins/webpack-ts|Pack the *@nativescript/webpack* plugin and bundle the [template-hello-world-ts](https://github.com/NativeScript/template-hello-world-ts) template app.|
|`ng`|ci/jenkins/webpack-ng|Pack the *@nativescript/webpack* plugin and bundle the [template-hello-world-ng](https://github.com/NativeScript/template-hello-world-ng) template app.|
|`groceries`|ci/jenkins/webpack-groceries|Pack the *@nativescript/webpack* plugin and bundle the [Groceries](https://github.com/NativeScript/sample-Groceries) app. |
|`sdk`|ci/jenkins/webpack-sdk|Pack the *@nativescript/webpack* plugin and bundle the [SDK](https://github.com/NativeScript/nativescript-sdk-examples-ng) app. |
|`testsappng`|ci/jenkins/webpack-testsappng|Pack the *@nativescript/webpack* plugin and bundle the [tests-app-ng](https://github.com/NativeScript/tests-app-ng) app. |
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NativeScript Webpack

This repository contains the code for the nativescript-dev-webpack plugin which helps in webpacking [NativeScript](https://www.nativescript.org/) apps.
This repository contains the code for the @nativescript/webpack plugin which helps in webpacking [NativeScript](https://www.nativescript.org/) apps.

JavaScript code and general asset bundling have been a member of the web developer toolbox for a long time. Tools like Webpack have been providing support for an enjoyable development experience that lets you assemble client-side code from various module sources and formats and then package it together. Most importantly, they allow for page load time optimizations that reduce or parallelize the number of requests a browser makes to the server.

Expand Down Expand Up @@ -31,7 +31,7 @@ For more details, see the [NativeScript docs for building with webpack](http://d
## Usage

```sh
$ npm install --save-dev nativescript-dev-webpack
$ npm install --save-dev @nativescript/webpack

$ tns run android
or
Expand Down
2 changes: 1 addition & 1 deletion android-app-components-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = function (source, map) {
const imports = modules.map(convertSlashesInPath)
.map(m => `require("${m}");`).join("\n");
const augmentedSource = `
let applicationCheckPlatform = require("tns-core-modules/application");
let applicationCheckPlatform = require("@nativescript/core/application");
if (applicationCheckPlatform.android && !global["__snapshot"]) {
${imports}
}
Expand Down
4 changes: 2 additions & 2 deletions apply-css-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ module.exports = function (content, map) {
}

content += `
const application = require("tns-core-modules/application");
require("tns-core-modules/ui/styling/style-scope");
const application = require("@nativescript/core/application");
require("@nativescript/core/ui/styling/style-scope");

if (typeof exports.forEach === "function") {
exports.forEach(cssExport => {
Expand Down
12 changes: 6 additions & 6 deletions bundle-config-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ const loader: loader.Loader = function (source, map) {

if (!registerModules) {
registerModules = defaultMatch;
for (const key in ignoredFiles) {
for (const key in <any>ignoredFiles) {
registerModules = `(?<!${escapeRegExp(ignoredFiles[key])})` + registerModules;
}
registerModules = new RegExp(registerModules);
registerModules = <any>new RegExp(registerModules);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opt for as T for type casting.

This any casting seems dangerous and seemingly dances around the typings issues that exist here, while functionally identical to before, is it safe? Looks more like the upstream typings are not ideal for this

Personally i'd opt for something more typesafe given the typings for ignoredFiles:

    let registerModulesSafe: RegExp;

    if (!registerModules) {
        registerModules = defaultMatch;

        // I assume you don't want to use a boolean
        if (Array.isArray(ignoredFiles)) {
            for (const ignoredFile of ignoredFiles) {
                registerModules += `(?<!${escapeRegExp(ignoredFile)})`;
            }
        } else if (typeof ignoredFiles === "string") {
            registerModules += `(?<!${escapeRegExp(ignoredFiles)})`;
        }

        registerModulesSafe = new RegExp(registerModules) as any;
    }

Then you can more safely load this expression further down:

    } else if (registerModules || registerModulesSafe) {
...
            const context = require.context("~/", true, ${registerModules || registerModulesSafe});
...
    }

}

if (unitTesting) {
Expand All @@ -34,7 +34,7 @@ const loader: loader.Loader = function (source, map) {

const hmr = `
if (module.hot) {
const hmrUpdate = require("nativescript-dev-webpack/hmr").hmrUpdate;
const hmrUpdate = require("@nativescript/webpack/hmr").hmrUpdate;
global.__coreModulesLiveSync = global.__onLiveSync;

global.__onLiveSync = function () {
Expand All @@ -54,7 +54,7 @@ const loader: loader.Loader = function (source, map) {
}
`;

let sourceModule = "tns-core-modules";
let sourceModule = "@nativescript/core";

if (platform && platform !== "ios" && platform !== "android") {
sourceModule = `nativescript-platform-${platform}`;
Expand Down Expand Up @@ -88,8 +88,8 @@ const loader: loader.Loader = function (source, map) {
source = `
require("${
angular ?
'nativescript-dev-webpack/load-application-css-angular' :
'nativescript-dev-webpack/load-application-css-regular'
'@nativescript/webpack/load-application-css-angular' :
'@nativescript/webpack/load-application-css-regular'
}")();
${source}
`;
Expand Down
2 changes: 1 addition & 1 deletion css2json-loader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe("css2jsonLoader", () => {
it("inlines css2json loader in imports if option is provided", (done) => {
const loaderContext = {
callback: (error, source: string, map) => {
expect(source).toContain(`global.registerModule("./custom.css", () => require("!nativescript-dev-webpack/css2json-loader?useForImports!./custom.css"))`);
expect(source).toContain(`global.registerModule("./custom.css", () => require("!@nativescript/webpack/css2json-loader?useForImports!./custom.css"))`);
expect(source).toContain(`{"type":"declaration","property":"background-color","value":"#7f9"}`);

done();
Expand Down
4 changes: 2 additions & 2 deletions css2json-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getOptions, urlToRequest } from "loader-utils";

const betweenQuotesPattern = /('|")(.*?)\1/;
const unpackUrlPattern = /url\(([^\)]+)\)/;
const inlineLoader = "!nativescript-dev-webpack/css2json-loader?useForImports!"
const inlineLoader = "!@nativescript/webpack/css2json-loader?useForImports!"

const loader: loader.Loader = function (content: string, map) {
const options = getOptions(this) || {};
Expand All @@ -26,7 +26,7 @@ const loader: loader.Loader = function (content: string, map) {
}
});
const str = JSON.stringify(ast, (k, v) => k === "position" ? undefined : v);
this.callback(null, `${dependencies.join("\n")}module.exports = ${str};`, map);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is removing map here safe? Is this for sourcemap generation?

this.callback(null, `${dependencies.join("\n")}module.exports = ${str};`);
}

function getImportRules(ast: Stylesheet): Import[] {
Expand Down
2 changes: 1 addition & 1 deletion demo/AngularApp/app/activity.android.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { setActivityCallbacks, AndroidActivityCallbacks } from "tns-core-modules/ui/frame";
import { setActivityCallbacks, AndroidActivityCallbacks } from "@nativescript/core/ui/frame";

@JavaProxy("org.myApp.MainActivity")
class Activity extends androidx.appcompat.app.AppCompatActivity {
Expand Down
6 changes: 3 additions & 3 deletions demo/AngularApp/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
import { NativeScriptModule } from "@nativescript/angular";
import { AppRoutingModule } from "./app.routing";
import { AppComponent } from "./app.component";

Expand All @@ -10,10 +10,10 @@ import { ItemDetailComponent } from "./item/item-detail.component";
// import { PlayfulSpirit } from "./directive";

// Uncomment and add to NgModule imports if you need to use two-way binding
// import { NativeScriptFormsModule } from "nativescript-angular/forms";
// import { NativeScriptFormsModule } from "@nativescript/angular";

// Uncomment and add to NgModule imports if you need to use the HTTP wrapper
// import { NativeScriptHttpModule } from "nativescript-angular/http";
// import { NativeScriptHttpModule } from "@nativescript/angular";

@NgModule({
bootstrap: [
Expand Down
4 changes: 2 additions & 2 deletions demo/AngularApp/app/app.routing.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NgModule } from "@angular/core";
import { NativeScriptRouterModule } from "nativescript-angular/router";
import { NativeScriptRouterModule } from "@nativescript/angular";
import { Routes } from "@angular/router";

import { ItemsComponent } from "./item/items.component";
Expand All @@ -11,7 +11,7 @@ const routes: Routes = [
{ path: "item/:id", component: ItemDetailComponent },
{
path: "ninjas",
loadChildren: "./ninjas/ninjas.module#NinjasModule",
loadChildren: () => import("./ninjas/ninjas.module").then(m => m.NinjasModule)
},

];
Expand Down
7 changes: 0 additions & 7 deletions demo/AngularApp/app/main.aot.ts

This file was deleted.

4 changes: 2 additions & 2 deletions demo/AngularApp/app/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// this import should be first in order to load some required settings (like globals and reflect-metadata)
import { platformNativeScriptDynamic } from "nativescript-angular/platform";
import { platformNativeScript } from "@nativescript/angular";
import { AppModule } from "./app.module";

platformNativeScriptDynamic().bootstrapModule(AppModule);
platformNativeScript().bootstrapModule(AppModule);
3 changes: 1 addition & 2 deletions demo/AngularApp/app/ninjas/details/ninja.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { NativeScriptCommonModule } from "nativescript-angular/common";
import { NativeScriptCommonModule, NativeScriptRouterModule } from "@nativescript/angular";
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
import { NativeScriptRouterModule } from "nativescript-angular/router";

import { NinjaComponent } from "./ninja.component";
import { routes } from "./ninja.routes";
Expand Down
3 changes: 1 addition & 2 deletions demo/AngularApp/app/ninjas/ninjas.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { NativeScriptCommonModule } from "nativescript-angular/common";
import { NativeScriptCommonModule, NativeScriptRouterModule } from "@nativescript/angular";
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
import { NativeScriptRouterModule } from "nativescript-angular/router";

import { NinjasComponent } from "./ninjas.component";
import { routes } from "./ninjas.routes";
Expand Down
32 changes: 16 additions & 16 deletions demo/AngularApp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@
}
},
"dependencies": {
"@angular/common": "8.2.0",
"@angular/compiler": "8.2.0",
"@angular/core": "8.2.0",
"@angular/forms": "8.2.0",
"@angular/platform-browser": "8.2.0",
"@angular/platform-browser-dynamic": "8.2.0",
"@angular/router": "8.2.0",
"nativescript-angular": "next",
"@angular/common": "~10.0.0",
"@angular/compiler": "~10.0.0",
"@angular/core": "~10.0.0",
"@angular/forms": "~10.0.0",
"@angular/platform-browser": "~10.0.0",
"@angular/platform-browser-dynamic": "~10.0.0",
"@angular/router": "~10.0.0",
"@nativescript/angular": "next",
"@nativescript/core": "next",
"nativescript-theme-core": "~1.0.2",
"reflect-metadata": "~0.1.8",
"rxjs": "^6.3.3",
"tns-core-modules": "next",
"zone.js": "^0.9.1"
"rxjs": "^6.5.5",
"zone.js": "^0.10.3"
},
"devDependencies": {
"@angular/compiler-cli": "8.2.0",
"@ngtools/webpack": "8.2.0",
"@angular/compiler-cli": "~10.0.0",
"@ngtools/webpack": "~10.0.0",
"@types/chai": "~4.1.7",
"@types/mocha": "~5.2.5",
"@types/node": "~10.12.18",
Expand All @@ -42,12 +42,12 @@
"chai": "4.2.0",
"mochawesome": "~3.1.2",
"nativescript-dev-appium": "next",
"nativescript-dev-webpack": "next",
"@nativescript/webpack": "next",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: order

"node-sass": "^4.12.0",
"typescript": "~3.5.3"
"typescript": "~3.9.0"
},
"scripts": {
"setup": "npm pack ../../ && npm i -D nativescript-dev-webpack*.tgz",
"setup": "npm pack ../../ && npm i -D nativescript-webpack*.tgz",
"e2e": "tsc -p e2e && mocha --opts ../config/mocha.opts --recursive e2e --appiumCapsLocation ../config/appium.capabilities.json",
"compile-tests": "tsc -p e2e --watch"
}
Expand Down
4 changes: 0 additions & 4 deletions demo/AngularApp/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
"paths": {
"~/*": [
"app/*"
],
"*": [
"./node_modules/tns-core-modules/*",
"./node_modules/*"
]
}
},
Expand Down
2 changes: 1 addition & 1 deletion demo/JavaScriptApp/app/activity.android.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const frame = require("tns-core-modules/ui/frame");
const frame = require("@nativescript/core/ui/frame");

const superProto = androidx.appcompat.app.AppCompatActivity.prototype;
androidx.appcompat.app.AppCompatActivity.extend("org.myApp.MainActivity", {
Expand Down
2 changes: 1 addition & 1 deletion demo/JavaScriptApp/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ You can use this file to perform app-level initialization, but the primary
purpose of the file is to pass control to the app’s first module.
*/

var application = require("tns-core-modules/application");
var application = require("@nativescript/core/application");

application.run({ moduleName: "app-root" });

Expand Down
2 changes: 1 addition & 1 deletion demo/JavaScriptApp/app/main-page.android.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var frameModule = require("tns-core-modules/ui/frame");
var frameModule = require("@nativescript/core/ui/frame");
var createViewModel = require("./main-view-model").createViewModel;

function onNavigatingTo(args) {
Expand Down
2 changes: 1 addition & 1 deletion demo/JavaScriptApp/app/main-page.ios.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var frameModule = require("tns-core-modules/ui/frame");
var frameModule = require("@nativescript/core/ui/frame");
var createViewModel = require("./main-view-model").createViewModel;

function onNavigatingTo(args) {
Expand Down
2 changes: 1 addition & 1 deletion demo/JavaScriptApp/app/main-view-model.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var Observable = require("tns-core-modules/data/observable").Observable;
var Observable = require("@nativescript/core/data/observable").Observable;

function getMessage(counter) {
if (counter <= 0) {
Expand Down
1 change: 0 additions & 1 deletion demo/JavaScriptApp/app/references.d.ts

This file was deleted.

6 changes: 3 additions & 3 deletions demo/JavaScriptApp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"dependencies": {
"nativescript-theme-core": "~1.0.2",
"tns-core-modules": "next"
"@nativescript/core": "~6.5.8"
},
"devDependencies": {
"@types/chai": "~4.1.7",
Expand All @@ -28,11 +28,11 @@
"mocha": "~5.2.0",
"mochawesome": "~3.1.2",
"nativescript-dev-appium": "next",
"nativescript-dev-webpack": "next",
"@nativescript/webpack": "next",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: order

"node-sass": "4.12.0"
},
"scripts": {
"setup": "npm pack ../../ && npm i -D nativescript-dev-webpack*.tgz",
"setup": "npm pack ../../ && npm i -D nativescript-webpack*.tgz",
"e2e": "mocha --opts ../config/mocha.opts --recursive e2e --appiumCapsLocation ../config/appium.capabilities.json"
}
}
2 changes: 1 addition & 1 deletion demo/TypeScriptApp/app/activity.android.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {setActivityCallbacks, AndroidActivityCallbacks} from "tns-core-modules/ui/frame";
import {setActivityCallbacks, AndroidActivityCallbacks} from "@nativescript/core/ui/frame";

@JavaProxy("org.myApp.MainActivity")
class Activity extends androidx.appcompat.app.AppCompatActivity {
Expand Down
2 changes: 1 addition & 1 deletion demo/TypeScriptApp/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ You can use this file to perform app-level initialization, but the primary
purpose of the file is to pass control to the app’s first module.
*/

import * as app from 'tns-core-modules/application';
import * as app from '@nativescript/core/application';

app.run({ moduleName: "app-root" });

Expand Down
7 changes: 2 additions & 5 deletions demo/TypeScriptApp/app/main-page.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ a code-behind file. The code-behind is a great place to place your view
logic, and to set up your page’s data binding.
*/

import { EventData } from 'tns-core-modules/data/observable';
import { Page } from 'tns-core-modules/ui/page';
import { Label } from 'tns-core-modules/ui/label';
import * as frameModule from 'tns-core-modules/ui/frame';
import { EventData, Page, Label, Frame } from '@nativescript/core';
import { HelloWorldModel } from './main-view-model';

export function onNavigatingTo(args: EventData) {
Expand All @@ -17,6 +14,6 @@ export function onNavigatingTo(args: EventData) {
}

export function goToSecondPage(args) {
var topmost = frameModule.topmost();
var topmost = Frame.topmost();
topmost.navigate("views/second-page");
}
7 changes: 2 additions & 5 deletions demo/TypeScriptApp/app/main-page.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ a code-behind file. The code-behind is a great place to place your view
logic, and to set up your page’s data binding.
*/

import { EventData } from 'tns-core-modules/data/observable';
import { Page } from 'tns-core-modules/ui/page';
import { EventData, Page, Label, Frame } from '@nativescript/core';
import { HelloWorldModel } from './main-view-model';
import { Label } from 'tns-core-modules/ui/label';
import * as frameModule from 'tns-core-modules/ui/frame';

// Event handler for Page "navigatingTo" event attached in main-page.xml
export function onNavigatingTo(args: EventData) {
Expand All @@ -35,6 +32,6 @@ export function onNavigatingTo(args: EventData) {
}

export function goToSecondPage(args) {
var topmost = frameModule.topmost();
var topmost = Frame.topmost();
topmost.navigate("views/second-page");
}
2 changes: 1 addition & 1 deletion demo/TypeScriptApp/app/main-view-model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Observable} from 'tns-core-modules/data/observable';
import {Observable} from '@nativescript/core';

export class HelloWorldModel extends Observable {

Expand Down
Loading