which angular2 js file should be added in on the client side? - npm

I am a semi noob in web development.
I just started playing around with angular2 today. And i ran into a problem..
If I were to install angular2 with npm to my local computer, which file is the js file that should be linked to the html page that show up on the client?
In their guide, i see a file called /node_modules/angular2/bundles/angular2.sfx.dev.js. But i don't even see this file at all.
Is there some script that i should run to build that file? Or is the file renamed? I am really confused.
I tried some file /angular2/bundles/angular2.js, but it doesn't even export ng variable to window!
I see that in https://code.angularjs.org/2.0.0-alpha.44/angular2.sfx.dev.js, eventually ng gets exported. But what changed in alpha 53? (the version i get for doing npm install angular2)

In my projects, I a using
"node_modules/angular2/bundles/angular2.dev.js"
You might additionally need to install/add systemjs, just in case you are using the systemjs library.

Related

Are create-react-app files visible on client side?

I'm currently experimenting with react and express and I wanted to know if react files are hidden, what m trying to do right now is encrypting api responses server side then decrypting it in the frontend, but having the key visible to everyone makes the entire thing useless
When you deploy your React application, your entire source code is visible to everyone from the sources tab of the dev tools.
This is not an issue with the create-react-app but all of the source code is added because of the source map which helps to easily identify the source of the bug that will occur on the live site in the future.
There is an easy way to fix it :
Create a file with the name .env in your project folder with the below code inside it :
GENERATE_SOURCEMAP=false
Or add this in package.json file :
scripts: {
"build": "GENERATE_SOURCEMAP=false react-scripts build"
}
Now, when you run 𝗻𝗽𝗺/yarn π—Ώπ˜‚π—» π—―π˜‚π—Άπ—Ήπ—± command from the terminal, It will generate a
π—―π˜‚π—Άπ—Ήπ—± folder with minified files without a source map that you can deploy to the production.
Hope you find my answer helpful !

Blazor Javascript isolation with NPM dependencies

I'm trying to use the new Blazor Javascript isolation feature. I'm importing my own JS file as per the example ExampleJsInterop.cs. It works until I try to import an NPM module from within my script. In my package.json I have set up a dependency on interactjs, and in my script I have added import interact from 'interactjs'; at the top.
I'm getting a Failed to resolve module specifier "interactjs" error. I'm not sure how to get past that.
Previously I was using Webpack to bundle my script and dependencies together into a single file that is added into my index.html as a tag. This was working fine, but I'm not sure how to continue using NPM packages with JS isolation.
Thanks!
A bit late, but I've just finished solving a similar issue.
The npm files are installed to the hidden node_modules folder. This isn't available to your script when you are running your app, unless you do something to make it available. however, even if you copied the interactjs file into your scripts folder it would still not work if it was an npm file. Those are meant to run in nodejs not a browser. So you would still need to use your bundler. I tried webpack, but had some issues with certain files so ended up with snowpack instead. I just finished a bunch of articles on javascript interop - part 4 deals with npm
I forgot that I left this question open for almost a year!
I ended up solving it using Snowpack to bundle the NPM package into the Blazor wwwroot folder. Credit goes to this article for pointing me in the right direction: https://nbarraud.github.io/js-in-blazor.html

Aurelia au run --watch... not watching

I downloaded an Aurelia project for testing purpose. After restoring the packages (npm install) and running the application (au run --watch). Now I see Start watching... I was curious about doing some changes (for example in contact-list.html) and seeing the website adjusting after pressing F5 (because of watching). It does not work. My changes are not reflecting in the running website. In the shell prompt where it is watching, nothing happened.
You can test by yourself with the project zipped below.
Zip of the Aurelia project
If I create a new Aurelia project from scratch (au new) and following the wizard, the watching works pretty well.
I don't know why it does not work in the project I downloaded (code provided by a Book for learning Aurelia).
What book is this?
Part of the problem is that the version of the CLI you are using is 2 years old. I would recommend getting the latest version of the CLI, creating a new project that uses RequireJS
au new
give new project a name
choose custom (3)
choose RequireJS (2)
choose Babel (1)
choose defaults for the rest
copy the src folder from your zip file over to it the newly created project
You'll need to run npm install bootstrap#3.3.6 --save or yarn add bootstrap#3.3.6 to pull down bootstrap.
Copy the link to bootstrap's css from your zip file's index.html to the new project
Delete the Promise.config line in src/main.js.
Then just run au run (--watch is no longer needed). It should work.

load local files outside NWJS app

When I work locally I want to share code among two or more (nwjs and other kinds of) projects. Folder structure:
-project 1
-project 2
-shared code
When releasing the apps I build the external files into a file inside each project app.
But I cannot access files outside the node-webkit/nwjs app folder.
I tried things like:
Setting "chromium-args": "--allow-file-access-from-files" in the manifest file but I think this is default now.
Using file:/// and chromium-extension:/// prepending the relative paths but I think this is only for absolute paths?
Load files dynamically and using path.relative( process.cwd(), "../shared_code/scripts/controllers/searchController.js" );
The user of the app will be able to put it anywhere on his computer.
Is it possible to load js and css files and images from outside the nwjs project folder locally?
nwjs sdk version 0.19.5
I had a similar problem trying to load images outside of the NW.js application. I found that this fixed my issues. Try adding this to your JSON manifest file. This worked for me...
"chromium-args": "--allow-file-access-from-files --allow-file-access --user-data-dir"
Just so you know, I had originally tried this...
"chromium-args": "--allow-file-access-from-files --allow-file-access --user-data-dir --mixed-context"
But it stopped jquery loading.
You can then access files with file:/// and use absolute paths anywhere on the machine.
I hope that helps.
For sharing code, when the code is (or can be) a node module, it's very helpful to be able to npm link it into your project. (It works the same with NW.js apps as for Node.js:)
cd shared-code
npm link
cd ../project-1
npm link shared-code
cd ../project-2
npm link shared-code

get bootstrap by NPM and include to html

Generally I am using CDN (or nuget) for including Bootstrap or other client side libraries to my website
Recently I read about NPM/Bower and other modern package-management tools, and decided to try
After some time of surfing and investigating I am now completely puzzled, how to just download and include bootstrap distrib css/js files to my page like it was....
1 st Try, I install bootstrap with NPM, it downloads whole Bootstrap with all sources/modules and etc to the node_module directory... well, I found distributions in node_modules/Bootstrap/dist folder
now questions:
Should I link node_modules/Bootstrap/dist/ css and js files to my site?
If yes, should I then deploy whole node_modules folder with website?
if No, and I know that npm package is modular and bla bla bla and should be included by require("bootstrap") than lots of other questions
is require("bootstrap") node js or some oter js function?
should I include some other node packages or js files in order require("bootstrap") to work
where should I write require("bootstrap") in html in script tag? create some js and include it or what?
2 nd try, Ok than I understand that npm might be package management for NodeJs server side, and got bower... but again it downloads the same files to another folder bower_components and again same questions...
As you mentioned, bower works well for this use case. Change the destination of the bower_components directory as described here How to change bower's default components folder?
then include as you normally would. Do not use the require function since that is for nodejs server side only.