This is a migrated thread and some comments may be shown as answers.

AoT not working

5 Answers 106 Views
JavaScript SDK
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jonathan Salomon
Top achievements
Rank 1
Jonathan Salomon asked on 18 Feb 2017, 07:35 PM

Hi guys,

I am trying to use everlive-sdk 1.9.2 with NativeScript 2.5 with the webpack plugin and get the following errors:

```

WARNING in ../~/everlive-sdk/dist/everlive.all.js
Module not found: Error: Can't resolve 'local-settings' in '/Users/joni/projects/testjoni/node_modules/everlive-sdk/dist'
 @ ../~/everlive-sdk/dist/everlive.all.js 30:423-448
 @ ./providers/backend.ts
 @ ./app.module.ngfactory.ts
 @ ./main.aot.ts

```

```

ERROR in ../~/node-localstorage/LocalStorage.js
Module not found: Error: Can't resolve 'fs' in '/Users/joni/projects/testjoni/node_modules/node-localstorage'
 @ ../~/node-localstorage/LocalStorage.js 9:7-20
 @ ../~/everlive-sdk/dist/everlive.all.js
 @ ./providers/backend.ts
 @ ./app.module.ngfactory.ts
 @ ./main.aot.ts

```

So I guess the Everlive SDK is not AoT ready? Any advice? Will there be an update to the SDK? Any estimation when it would be?

Thanks!

5 Answers, 1 is accepted

Sort by
0
Georgi Prodanov
Telerik team
answered on 21 Feb 2017, 06:16 PM
Hello Jonathan,

The missing "local-settings" module shouldn't be a concern - it's used for backwards compatibility when using the NativeScript local storage implementation. The message for it, which you shared, is a warning not an error and shouldn't affect the build process. At runtime, it will not be looked up.

The message about "fs" missing on the other hand is an error. I'm afraid we don't have much to go on when it comes to resolving it, though. The SDK should work in AOT mode, we haven't come across this error before. Please give us some more info, or maybe show us your code. For example what version of Node.js and NPM are you using? What NativeScript plugins are included in your project, which command did you use to start the bundling, at what point during the compilation do you get this error, which version of Webpack are you using?

This particular error is not something we've encountered or had any other reports of, so for the time being, new versions of the SDK are not planned to be changing anything regarding AoT compilation, since we are not aware of any confirmed issues yet. But if this turns out to be a problem on our side, we will resolve it as soon as we are able.

Regards,
Georgi Prodanov
Telerik by Progress
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
0
Jonathan Salomon
Top achievements
Rank 1
answered on 21 Feb 2017, 06:43 PM

Hi Georgi,

Here are some of the details that you requested. I know there are some other modules that don't support AoT as far as I can tell (like nativescript-telephony and my own nativescript-contacts-lite) which I will need to solve also, but I see the everlive SDK in the call stack in the error about fs, so that is why I thought that one is one of the problems. Also I don't see any *.metadata.json files in the everlive package which is one of the requirements for AoT from what I understand from here.

 

$ tns info
All NativeScript components versions information
┌──────────────────┬─────────────────┬────────────────┬─────────────┐
│ Component        │ Current version │ Latest version │ Information │
│ nativescript     │ 2.5.1           │ 2.5.1          │ Up to date  │
│ tns-core-modules │ 2.5.1           │ 2.5.1          │ Up to date  │
│ tns-android      │ 2.5.0           │ 2.5.0          │ Up to date  │
│ tns-ios          │ 2.5.0           │ 2.5.0          │ Up to date  │
└──────────────────┴─────────────────┴────────────────┴─────────────┘

 

package.json

"nativescript": {
    "id": "com.abhayastudios.friendy",
    "tns-ios": {
      "version": "2.5.0"
    },
    "tns-android": {
      "version": "2.5.0"
    }
  },
  "dependencies": {
    "@angular/common": "2.4.7",
    "@angular/compiler": "2.4.7",
    "@angular/core": "2.4.7",
    "@angular/forms": "2.4.7",
    "@angular/http": "2.4.7",
    "@angular/platform-browser": "2.4.7",
    "@angular/platform-browser-dynamic": "2.4.7",
    "@angular/router": "3.4.7",
    "everlive-sdk": "^1.9.2",
    "google-libphonenumber": "2.0.10",
    "nativescript-angular": "1.4.0",
    "nativescript-angular-snapshot": "1.4.0-5.5.372.32-1",
    "nativescript-contacts-lite": "^0.1.1",
    "nativescript-push-notifications": "^0.1.2",
    "nativescript-telephony": "^1.0.2",
    "nativescript-telerik-ui": "^1.6.0-2017.2.13.3",
    "nativescript-theme-core": "~1.0.2",
    "nativescript-toasts": "^1.0.3",
    "reflect-metadata": "~0.1.8",
    "rxjs": "~5.0.1",
    "tns-core-modules": "2.5.1"
  },

 

$ npm --version
4.0.2

$ node --version
v6.7.0

 

Let me know if you need anything else.

Thanks a lot!

 

0
Jonathan Salomon
Top achievements
Rank 1
answered on 21 Feb 2017, 06:45 PM

Ah and I followed the webpack instructions from the NS docs:

"devDependencies": {
    "@angular/compiler-cli": "~2.4.7",
    "@ngtools/webpack": "1.2.4",
    "babel-traverse": "6.23.1",
    "babel-types": "6.23.0",
    "babylon": "6.15.0",
    "copy-webpack-plugin": "~3.0.1",
    "extract-text-webpack-plugin": "~2.0.0-beta.4",
    "htmlparser2": "~3.9.2",
    "lazy": "1.0.11",
    "nativescript-css-loader": "~0.26.0",
    "nativescript-dev-android-snapshot": "^0.*.*",
    "nativescript-dev-typescript": "~0.3.5",
    "nativescript-dev-webpack": "^0.3.3",
    "raw-loader": "~0.5.1",
    "resolve-url-loader": "~1.6.0",
    "typescript": "~2.1.0",
    "webpack": "2.2.0",
    "webpack-sources": "~0.1.3",
    "zone.js": "~0.7.2"
  },
0
Georgi Prodanov
Telerik team
answered on 22 Feb 2017, 03:18 PM
Hi Jonathan,

Can you please make sure that you have the disabling of Nodejs shims in your webpack config?

The way it should be set up is in the (usually named) webpack.common.js file, you need to have a section for node shims, which features the "fs" module. This is what the config should look like, more or less:

{
    context: path.resolve("./app"),
    target: nativescriptTarget,
    entry: entry,
    output: { ... },
    resolve: { ... },
    node: {
        //Disable node shims that conflict with NativeScript
        "http": false,
        "timers": false,
        "setImmediate": false,
        "fs": "empty",
    }
}

Note the "fs": "empty" part - if you don't have that in your config, add it and try again. Let us know if this doesn't work and we can look into it further.

Regards,
Georgi Prodanov
Telerik by Progress
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
0
Jonathan Salomon
Top achievements
Rank 1
answered on 23 Feb 2017, 10:53 AM

Hi Georgi,

p w this makes the error about fs disappear. I am still not able to complete the compilation because it throws errors on other plugins. I will take it up with the authors of those plugins.

Thanks for your help so far!

Tags
JavaScript SDK
Asked by
Jonathan Salomon
Top achievements
Rank 1
Answers by
Georgi Prodanov
Telerik team
Jonathan Salomon
Top achievements
Rank 1
Share this question
or