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

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NativeScript/nativescript-dev-webpack
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.2.0
Choose a base ref
...
head repository: NativeScript/nativescript-dev-webpack
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: release
Choose a head ref
Loading
Showing with 1,702 additions and 1,268 deletions.
  1. +22 −1 .github/PULL_REQUEST_TEMPLATE.md
  2. +8 −1 .gitignore
  3. +2 −0 .npmignore
  4. +5 −0 .nycrc
  5. +102 −0 CHANGELOG.md
  6. +13 −2 androidProjectHelpers.js
  7. +33 −8 apply-css-loader.js
  8. +3 −0 bundle-config-loader.spec.ts
  9. +17 −14 bundle-config-loader.ts
  10. +0 −29 css2json-loader.js
  11. +79 −0 css2json-loader.spec.ts
  12. +62 −0 css2json-loader.ts
  13. +2 −1 demo/.gitignore
  14. +7 −8 demo/AngularApp/app/App_Resources/Android/app.gradle
  15. +3 −2 demo/AngularApp/app/package.json
  16. +13 −0 demo/AngularApp/custom-application-activity.webpack.config.js
  17. +3 −0 demo/AngularApp/nsconfig.json
  18. +1 −0 demo/AngularApp/package.json
  19. +0 −320 demo/AngularApp/webpack.config.js
  20. +1 −0 demo/JavaScriptApp/app/app.android.css
  21. 0 demo/JavaScriptApp/app/app.common.css
  22. +1 −0 demo/JavaScriptApp/app/app.ios.css
  23. +3 −2 demo/JavaScriptApp/app/package.json
  24. +13 −0 demo/JavaScriptApp/custom-application-activity.webpack.config.js
  25. +3 −0 demo/JavaScriptApp/nsconfig.json
  26. +1 −0 demo/JavaScriptApp/package.json
  27. +0 −259 demo/JavaScriptApp/webpack.config.js
  28. +3 −2 demo/TypeScriptApp/app/package.json
  29. +13 −0 demo/TypeScriptApp/custom-application-activity.webpack.config.js
  30. +1 −1 demo/TypeScriptApp/nsconfig.json
  31. +1 −0 demo/TypeScriptApp/package.json
  32. +0 −290 demo/TypeScriptApp/webpack.config.js
  33. +1 −1 dependencyManager.js
  34. +1 −1 host/resolver.ts
  35. +104 −3 index.js
  36. +1 −1 jasmine-config/jasmine.json
  37. +6 −1 lib/after-prepare.js
  38. +19 −2 lib/before-checkForChanges.js
  39. +26 −3 lib/utils.js
  40. +13 −4 package.json
  41. +7 −2 plugins/GenerateNativeScriptEntryPointsPlugin.js
  42. +9 −1 plugins/NativeScriptSnapshotPlugin/index.js
  43. +10 −3 plugins/NativeScriptSnapshotPlugin/options.json
  44. +29 −4 plugins/PlatformFSPlugin.ts
  45. +2 −3 plugins/WatchStateLoggerPlugin.ts
  46. +9 −1 snapshot/android/project-snapshot-generator-cli-ags-parser.js
  47. +50 −129 snapshot/android/project-snapshot-generator.js
  48. +324 −75 snapshot/android/snapshot-generator.js
  49. +61 −2 snapshot/android/utils.js
  50. +52 −15 templates/webpack.angular.js
  51. +32 −2 templates/webpack.config.spec.ts
  52. +33 −11 templates/webpack.javascript.js
  53. +38 −12 templates/webpack.typescript.js
  54. +58 −12 templates/webpack.vue.js
  55. +3 −12 utils/ast-utils.ts
  56. +25 −0 utils/tsconfig-utils.ts
  57. +315 −0 xml-namespace-loader.spec.ts
  58. +59 −28 xml-namespace-loader.js → xml-namespace-loader.ts
23 changes: 22 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -35,5 +35,26 @@ Migration steps:
[Provide a migration path for existing applications.]
-->

<!--
E2E TESTS
Additional e2e tests can be executed by comment including trigger phrase.
Phrases:
`test cli-smoke`: Smoke tests for `tns run`.
`test cli-create`: Tests for `tns create` commans.
`test cli-plugin`: Tests for `tns plugin *` commands.
`test cli-preview`: Tests for `tns preview` command.
`test cli-regression`: Tests for backward compatibility with old projects.
`test cli-resources`: Test for resource generate.
`test cli-tests`: Tests for `tns test` command.
`test cli-vue`: Smoke tests for VueJS projects based on {N} cli.
`test cli-templates`: Tests for `tns run` on {N} templates.
`test cli-misc`:
`test cli-build`: Test for `tns build` on emulators/simulators
`test cli-device`: Test for `tns run` on real devices
`test cli-debug`: Tests for `tns debug`
`test cli-run`: Tests for `tns run`
-->

[CLA]: http://www.nativescript.org/cla
[CLA]: http://www.nativescript.org/cla
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -31,10 +31,17 @@ jasmine-config/reporter.js
bundle-config-loader.d.ts
bundle-config-loader.js

xml-namespace-loader.d.ts
xml-namespace-loader.js

css2json-loader.d.ts
css2json-loader.js

**/*.spec.js*
**/*.spec.d.ts*

hooks
.DS_Store

.nyc_output
coverage
!projectHelpers.spec.js
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -7,6 +7,8 @@ demo
*.spec.*
.vscode/
.github/
.nyc_output
coverage/
jasmine-config/
CONTRIBUTING.md
CODE_OF_CONDUCT.md
5 changes: 5 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "@istanbuljs/nyc-config-typescript",
"exclude": ["/demo/**"],
"reporter": ["text", "lcov"]
}
102 changes: 102 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,105 @@
<a name="1.5.1"></a>
## [1.5.1](https://github.com/NativeScript/nativescript-dev-webpack/compare/v1.5.0...v1.5.1) (2020-02-25)


### Bug Fixes

* `The provided Android NDK is vnull while the recommended one is v21.0.6113669` error in some cases ([23aa6c5](https://github.com/NativeScript/nativescript-dev-webpack/commit/23aa6c5))
* AOT compilation of multiple workers should work ([af5cb84](https://github.com/NativeScript/nativescript-dev-webpack/commit/af5cb84))
* replace extension coming from package.json ([a04c0f8](https://github.com/NativeScript/nativescript-dev-webpack/commit/a04c0f8))


### Features

* Add .kt extension to known entry types ([55b56c8](https://github.com/NativeScript/nativescript-dev-webpack/commit/55b56c8))
* Add .kt extension to known ones ([6e145a4](https://github.com/NativeScript/nativescript-dev-webpack/commit/6e145a4))



<a name="1.5.0"></a>
# [1.5.0](https://github.com/NativeScript/nativescript-dev-webpack/compare/1.4.1...1.5.0) (2020-02-04)


### Bug Fixes

* ensure the js snapshot entry dir if not created (avoid ENOENT error) ([2a0eaf6](https://github.com/NativeScript/nativescript-dev-webpack/commit/2a0eaf6))
* stop searching for snapshot artefacts when the snapshot tools are skipped (it's a cloud build, there aren't any snapshot artefacts locally) ([b8da140](https://github.com/NativeScript/nativescript-dev-webpack/commit/b8da140))


### Features

* **dependencies:** updated `[@angular](https://github.com/angular)/compiler-cli` dependency ([1dbcbf2](https://github.com/NativeScript/nativescript-dev-webpack/commit/1dbcbf2)), closes [#1114](https://github.com/NativeScript/nativescript-dev-webpack/issues/1114)
* allow extending webpack.config.js through env ([69ace1e](https://github.com/NativeScript/nativescript-dev-webpack/commit/69ace1e))



<a name="1.4.1"></a>
## [1.4.1](https://github.com/NativeScript/nativescript-dev-webpack/compare/1.4.0...1.4.1) (2020-01-07)


### Bug Fixes

* add missing tsconfig paths when the app is using only scoped modules and angular ([87ec157](https://github.com/NativeScript/nativescript-dev-webpack/commit/87ec157))
* handle missing paths obj in tsconfig ([867a9f1](https://github.com/NativeScript/nativescript-dev-webpack/commit/867a9f1))


<a name="1.4.0"></a>
# [1.4.0](https://github.com/NativeScript/nativescript-dev-webpack/compare/1.3.1...1.4.0) (2019-12-08)

### Bug Fixes

* add import of `.css` file into another `.css` file ([c5e4552](https://github.com/NativeScript/nativescript-dev-webpack/commit/c5e4552))
* avoid duplicate modules from tns-core-modules and [@nativescript](https://github.com/nativescript)/core causing app crashes on Android ([b74b231](https://github.com/NativeScript/nativescript-dev-webpack/commit/b74b231))
* bundle emitted on save without changes ([2d01df9](https://github.com/NativeScript/nativescript-dev-webpack/commit/2d01df9)), closes [/github.com/webpack/webpack/blob/4056506488c1e071dfc9a0127daa61bf531170bf/lib/Compiler.js#L326](https://github.com//github.com/webpack/webpack/blob/4056506488c1e071dfc9a0127daa61bf531170bf/lib/Compiler.js/issues/L326)
* fix module import of local css files ([2c0a36e](https://github.com/NativeScript/nativescript-dev-webpack/commit/2c0a36e)), closes [/github.com/webpack-contrib/css-loader/blob/967fb66da2545f04055eb0900a69f86e484dd842/src/utils.js#L220](https://github.com//github.com/webpack-contrib/css-loader/blob/967fb66da2545f04055eb0900a69f86e484dd842/src/utils.js/issues/L220)
* remove the tns-core-modules dependency in order to allow [@nativescrip](https://github.com/nativescrip)/core migration ([7d60958](https://github.com/NativeScript/nativescript-dev-webpack/commit/7d60958))
* stop ignoring the initial hot updates ([d032e4c](https://github.com/NativeScript/nativescript-dev-webpack/commit/d032e4c))
* stop on compilation error in typescript applications ([df7d122](https://github.com/NativeScript/nativescript-dev-webpack/commit/df7d122))
* update worker loader in order to fix HMR ([5ad141e](https://github.com/NativeScript/nativescript-dev-webpack/commit/5ad141e))

### Features

* snapshot in Docker on macOS with Android runtime 6.3.0 or higher as it will not contain snapshot tools for macOS anymore ([9e99683](https://github.com/NativeScript/nativescript-dev-webpack/commit/9e99683))
* stop using the proxy `tns-core-modules` package when the `[@nativescript](https://github.com/nativescript)/core` is available ([061b270](https://github.com/NativeScript/nativescript-dev-webpack/commit/061b270))



<a name="1.3.0"></a>
# [1.3.0](https://github.com/NativeScript/nativescript-dev-webpack/compare/1.2.1...1.3.0) (2019-10-31)


### Bug Fixes

* exclude files from tests folder from built application ([c61f10e](https://github.com/NativeScript/nativescript-dev-webpack/commit/c61f10e))
* fix dependencies in package.json ([eefd042](https://github.com/NativeScript/nativescript-dev-webpack/commit/eefd042)), closes [/github.com/NativeScript/nativescript-dev-webpack/blob/master/bundle-config-loader.ts#L4](https://github.com//github.com/NativeScript/nativescript-dev-webpack/blob/master/bundle-config-loader.ts/issues/L4) [/github.com/NativeScript/nativescript-dev-webpack/blob/2978b81b5a8100774b2bb4a331ac8637205927b8/package.json#L54](https://github.com//github.com/NativeScript/nativescript-dev-webpack/blob/2978b81b5a8100774b2bb4a331ac8637205927b8/package.json/issues/L54)
* fix xxd path for local snapshots generation ([f63d493](https://github.com/NativeScript/nativescript-dev-webpack/commit/f63d493))
* handle correctly webpack compilation errors ([363c4da](https://github.com/NativeScript/nativescript-dev-webpack/commit/363c4da))
* handle imports like [@import](https://github.com/import) url("./xxx.css") ([8921120](https://github.com/NativeScript/nativescript-dev-webpack/commit/8921120))
* search for the proper NDK executable on Windows ([f93bb6c](https://github.com/NativeScript/nativescript-dev-webpack/commit/f93bb6c))
* Unbound namespace error with ios and android ([#1053](https://github.com/NativeScript/nativescript-dev-webpack/issues/1053)) ([6cd6efe](https://github.com/NativeScript/nativescript-dev-webpack/commit/6cd6efe))


### Features

* add useForImports option ([632af4f](https://github.com/NativeScript/nativescript-dev-webpack/commit/632af4f))
* ensure valid CLI version when Windows snapshot is requested ([3a687c0](https://github.com/NativeScript/nativescript-dev-webpack/commit/3a687c0))
* support [@nativescript](https://github.com/nativescript) scope in host resolver ([efda509](https://github.com/NativeScript/nativescript-dev-webpack/commit/efda509))
* support useLibs though env.compileSnapshot and calculate the NDK path internally ([5431bd7](https://github.com/NativeScript/nativescript-dev-webpack/commit/5431bd7))
* support V8 snapshots on Windows ([2e9b753](https://github.com/NativeScript/nativescript-dev-webpack/commit/2e9b753))
* use css2json loader by default ([6b0c9ae](https://github.com/NativeScript/nativescript-dev-webpack/commit/6b0c9ae))



<a name="1.2.1"></a>
## [1.2.1](https://github.com/NativeScript/nativescript-dev-webpack/compare/1.2.0...1.2.1) (2019-10-03)


### Features

* snapshot in docker container when the local tools are not available ([6861d22](https://github.com/NativeScript/nativescript-dev-webpack/commit/6861d22))



<a name="1.2.0"></a>
# [1.2.0](https://github.com/NativeScript/nativescript-dev-webpack/compare/1.1.1...1.2.0) (2019-09-03)

15 changes: 13 additions & 2 deletions androidProjectHelpers.js
Original file line number Diff line number Diff line change
@@ -47,6 +47,16 @@ const getMksnapshotParams = (projectDir) => {
}
};

const getRuntimeNdkRevision = (projectDir) => {
try {
const androidSettingsJSON = getAndroidSettingsJson(projectDir);
const result = androidSettingsJSON && androidSettingsJSON.ndkRevision;
return result;
} catch (e) {
return null;
}
};

const getAndroidSettingsJson = projectDir => {
const androidSettingsJsonPath = resolve(projectDir, PLATFORMS_ANDROID, "settings.json");
if (existsSync(androidSettingsJsonPath)) {
@@ -62,5 +72,6 @@ module.exports = {
ANDROID_CONFIGURATIONS_PATH,
getAndroidRuntimeVersion,
getAndroidV8Version,
getMksnapshotParams
};
getMksnapshotParams,
getRuntimeNdkRevision
};
41 changes: 33 additions & 8 deletions apply-css-loader.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,43 @@
const cssLoaderWarning = "The apply-css-loader expects the file to be pre-processed by css-loader. It might not work properly. Please check your webpack configuration";

function checkForCssLoader(loaders, loaderIndex) {
if (!loaders) {
return false;
}

for (var i = loaderIndex + 1; i < loaders.length; i++) {
const loader = loaders[i];
if (loader.path && loader.path.indexOf("css-loader") > 0) {
return true;
}
}

return false;
}

module.exports = function (content, map) {
if (this.request.match(/\/app\.(css|scss|less|sass)$/)) {
return content;
}

// Emit a warning if the file was not processed by the css-loader.
if (!checkForCssLoader(this.loaders, this.loaderIndex)) {
this.emitWarning(new Error(cssLoaderWarning));
}

content += `
const application = require("tns-core-modules/application");
require("tns-core-modules/ui/styling/style-scope");
exports.forEach(cssExport => {
if (cssExport.length > 1 && cssExport[1]) {
// applying the second item of the export as it contains the css contents
application.addCss(cssExport[1]);
}
});
`;
if (typeof exports.forEach === "function") {
exports.forEach(cssExport => {
if (cssExport.length > 1 && cssExport[1]) {
// applying the second item of the export as it contains the css contents
application.addCss(cssExport[1]);
}
});
}
`;

this.callback(null, content, map);
}
}
3 changes: 3 additions & 0 deletions bundle-config-loader.spec.ts
Original file line number Diff line number Diff line change
@@ -39,6 +39,9 @@ const defaultTestFiles = {
"./_app-variables.scss": false, // do not include scss partial files
"./App_Resources/Android/src/main/res/values/colors.xml": false, // do not include App_Resources
"./App_Resources/Android/src/main/AndroidManifest.xml": false, // do not include App_Resources
"./tests/example.js": false, // do not include files from tests folder
"./tests/component1/model1/file1.js": false, // do not include files from tests folder
"./components/tests/example.js": true,
};

const loaderOptionsWithIgnore = {
31 changes: 17 additions & 14 deletions bundle-config-loader.ts
Original file line number Diff line number Diff line change
@@ -3,13 +3,14 @@ import { loader } from "webpack";
import { getOptions } from "loader-utils";
import * as escapeRegExp from "escape-string-regexp";

// Matches all source, markup and style files that are not in App_Resources
const defaultMatch = "(?<!\\bApp_Resources\\b.*)\\.(xml|css|js|(?<!\\.d\\.)ts|(?<!\\b_[\\w-]*\\.)scss)$";
// Matches all source, markup and style files that are not in App_Resources and in tests folder
const defaultMatch = "(?<!\\bApp_Resources\\b.*)(?<!\\.\\/\\btests\\b\\/.*?)\\.(xml|css|js|kt|(?<!\\.d\\.)ts|(?<!\\b_[\\w-]*\\.)scss)$";

const loader: loader.Loader = function (source, map) {
let {
angular = false,
loadCss = true,
platform,
unitTesting,
projectRoot,
appFullPath,
@@ -34,31 +35,33 @@ const loader: loader.Loader = function (source, map) {
const hmr = `
if (module.hot) {
const hmrUpdate = require("nativescript-dev-webpack/hmr").hmrUpdate;
global.__initialHmrUpdate = true;
global.__hmrSyncBackup = global.__onLiveSync;
global.__coreModulesLiveSync = global.__onLiveSync;
global.__onLiveSync = function () {
// handle hot updated on LiveSync
hmrUpdate();
};
global.hmrRefresh = function({ type, path } = {}) {
if (global.__initialHmrUpdate) {
return;
}
// the hot updates are applied, ask the modules to apply the changes
setTimeout(() => {
global.__hmrSyncBackup({ type, path });
global.__coreModulesLiveSync({ type, path });
});
};
hmrUpdate().then(() => {
global.__initialHmrUpdate = false;
})
// handle hot updated on initial app start
hmrUpdate();
}
`;

let sourceModule = "tns-core-modules";

if (platform && platform !== "ios" && platform !== "android") {
sourceModule = `nativescript-platform-${platform}`;
}

source = `
require("tns-core-modules/bundle-entry-points");
require("${sourceModule}/bundle-entry-points");
${source}
`;

@@ -96,4 +99,4 @@ const loader: loader.Loader = function (source, map) {
};


export default loader;
export default loader;
29 changes: 0 additions & 29 deletions css2json-loader.js

This file was deleted.

Loading