-
-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable NPM as package manager for NativeScript projects #362
Comments
Kudos! Regarding the nativescript-specific properties, a separate key looks like the cleanest solution. As per having nativescript "engine" prerequisite, though cumbersome in the beginning, it is the cleanest approach when having to avoid unsupported nodejs modules. Shim creation could get easy by using the original NodeJS module as a git submodule of the shim repo. |
Additionally, the root node_modules folder might hold preprocessing-related packages (i.e. grunt, gulp, plugins for them, etc.) that should not get copied to the NativeScript application folder... |
☝️ Good point about |
First of all, this look spectacular. I'm a big fan of this setup.
I'm also a fan of the single “nativescript” key.
This will be a nuisance for maintenance but I still think it's a good idea. We might want to make it a warning rather than a hard requirement. I believe that's what Cordova does for their Out of curiosity is the plan to have the cross-platform modules follow these same conventions? As we add modules that require certain permissions (e.g. the camera) I could see dog fooding these same ideas being pretty handy. I've already had to manually upgrade |
I +1 the idea of having a property called Also, publishing modules to npm will definately increase the speed at which people adopt Nativescript since it'd be trivial to publish re-usable packages that use native code. |
I think that supporting NPM is a must. People is already writing cross-platform modules (I am), and publishing to NPM will accelerate the usage of Nativescript. @tjvantoll idea of having a "nativescript-core" module that is upgradeable via NPM sounds like heaven. |
+1 to being able to take a dependency on the |
👍 |
Has there been any progress on this? |
@RangerMauve Yes we are currently working on this. You can check the tasks we have defined in the issue description. |
This issue is related to Node.js API support feature. |
Mind adding Node.js/io.js API support to the checklist? With same-named modules having different APIs, and the same module system being used, this will inevitably trip up a lot of people in a hurry. |
Shouldn't the |
Having thought about it for a little, I realized preparing JavaScript for a mobile app is very much like preparing it for the browser. You'd want to ensure the minimal amount of code gets included, process it if you're doing something clever and perhaps even minify it. Assuming the root |
I totally agree with what @moll is saying. Maybe it'd be useful to integrate something like browserify or webpack for building up the dependencies into a single JS file in the build step. |
@moll Just as an fyi I've requested that the |
@tjvantoll: Great. Thanks. Wow, just switched to using Browserify as a preprocessor, and after running |
Make sure you install Browserify with For the superfluous things I think that's just something you might have to take up with the individual modules; they really should be using an |
Yep, used devDeps there and still had them copied to I am one of those module authors who intentionally puts superfluous things in their release tarball. Things like tests and documentation. Vital for development, but definitely not meant to be sent down browsers or up mobile apps. :) I don't think copying node_modules is necessarily a path NativeScript CLI should go down on. Perhaps for development it'd be nice if one could symlink the whole app dir to platforms' app dir and have things resolve through |
I tend to agree; you have good points. I'm curious what @ligaz's thoughts on this are. |
We do plan to provide hooks as extensibility point (they are already there in the common lib, but not enabled in NativeScript CLI) at some near future as part of our transpilers support #493. Currently we prepare a couple of things:
We will think about how we can abstract our current default |
Hey guys, I'm using the Telerik platform (browser-based), and I used the GUI to install an NPM package, this one, and I could not |
Hey all! I'm using Telerik AppBuilder, trying to import nativescript-background-http module in my app and get error Module "nativescript-background-http" not found. When i'm looking for it in Properties => Dependencies, it is present in installed NPM Packages. Can i make smth with it? |
Hey Gertus88, We will be glad to assist with resolving the issue once we can reproduce it. |
I guess am using telrik platform . The platform already configured the nom packages into nod_module. do i need to any config to run the native script apps using NPM packages ? |
A common use case for NativeScript developers is the ability to install pure JavaScript modules from NPM. Currently this process is cumbersome and it is not straightforward how to
require
modules that have dependencies due to the nesting ofnode_modules
folders. The end goal is thatnpm install ...
should work out of the box.Relying on 'standards'
In order to support this a couple of things have to be changed in the CLI. Currently we create a project file
.tnsproject
that stores the app id (bundle identifier) along with the currently used version of each runtime. We plan to replace this file withpackage.json
that will be compatible with NPM package json format. Here is the structure of a simple app following this rule:Preparing for a better world
Assuming we have
package.json
in the root of the project will allow us to supportnpm install lodash --save
which will installlodash
intonode_modules
folder and save it as dependency in thepackage.json
. All good but howlodash
will end-up in thetns_modules
folder of the app? This is where the second significant change will come into place. We will extend theprepare
command to recursively transform thenode_modules
folder contents intotns_modules
in the native platform project. This transformation should exclude all modules defined in thedevDependencies
section of thepackage.json
.Open questions:
What should be the way to add NativeScript specific properties to the
project.json
?tns_
ornativescript_
Example:nativescript
key. Example:Should we require NativeScript tailored modules published to NPM to have
nativescript
as anengine
?Example:
or
This will give us a couple of advantages:
node_modules
folder by providing shims for all Node APIs.Tasks
.tnsproject
and introducepackage.json
nativescript
key in thepackage.json
prepare
to copy the modules fromnode_modules
into platform native project 'tns_modules'prepare
devDependencies
.prepare
when copying the modules. We can consider things like symlinks or broccoli.js kind of infrastructure.The text was updated successfully, but these errors were encountered: