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

fix: bundling of Angular apps using linked TS plugins #505

Merged
merged 1 commit into from
Apr 24, 2018

Conversation

DimitarTachev
Copy link
Contributor

  • the webpack build is now following the symLinks in Angular apps
  • the root node_modules folder of the app now takes precedence over the local node_modules during module resolution (avoiding duplicate modules in the bundle when following symLinks)

What is the current behavior?

When you try to build the Angular demo of a plugin and the plugin source is linked in the demo, you will receive the following exception:

Error: ...demo-angular/node_modules/nativescript-your-plugin/your-plugin.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format (https://goo.gl/jB3GVv).
at NativeScriptAngularCompilerPlugin.getCompiledFile...

and even if you include the problematic demo-angular/node_modules/nativescript-your-plugin/your-plugin.ts file using the files or include tsconfig properties as described in the exception message, you will still get the same error because the file is linked and this is not its real location.

What is the new behavior?

When you try to build the Angular demo of a plugin and the plugin source is linked in the demo, you will receive the following exception:

Error: ...src/your-plugin.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
at NativeScriptAngularCompilerPlugin.getCompiledFile...

and when you include the problematic src/your-plugin.ts file using the files or include tsconfig properties as described in the exception message, you will get the app built and running.

Why in Angular apps only?

It seems that the @ngtools/webpack typescript loader used in the Angular apps requires real paths to the ts files, while the awesome-typescript-loader used in the Typescript NativeScript apps is working fine with the linked paths.

…files inside + the root node_modules of the app now takes precedence over the local node_modules during module resolution (avoiding duplicate modules in the bundle)
@sis0k0 sis0k0 changed the title Fix bundling of Angular app using linked plugins with typescript files. fix: bundling of Angular apps using linked TS plugins Apr 24, 2018
@sis0k0
Copy link
Contributor

sis0k0 commented Apr 24, 2018

Plugin authors should also add the following to their app's tsconfig./json:

//...
    "include": [
        "../src",
        "**/*"
    ],
    "exclude": [
        "../src/node_modules",
        "node_modules",
        "platforms"
    ],

where ../src is the path to the symlinked plugin.

@sis0k0 sis0k0 merged commit 41779ad into master Apr 24, 2018
@sis0k0 sis0k0 deleted the tachev/fix-linked-plugins-bundle branch April 24, 2018 21:49
@nikeshjain
Copy link

nikeshjain commented May 3, 2018

Hello Stanimira,

We updated version of nativescript-dev-webpack to the latest version 0.11.0
We also updated tsconfig./json as mentioned below

...
"include": [
"../src",
"**/*"
],
"exclude": [
"../src/node_modules",
"node_modules",
"platforms"
],

When we build our iOS application using webpack, we are facing below issue:

ERROR in ./app.module.ngfactory.js
Module not found: Error: Can't resolve 'your-plugin/index' in '//**'
@ ./app.module.ngfactory.js 122:11-48
@ ./main.aot.ts

Please note that we are using NativeScript Version 4.0.

Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants