How to add .js file to netsuite SCA Denali / Mont-Blanc - netsuite

I am currently editing a Netsuite SCA implementation - and need to add a .js file to the site.
In SiteBuilder this was fairly simple with editing templates. However, with SCA it looks like we need quite a bit more configuration to make it happen.
I'd welcome some help from the community on how to add a .js file.
Thank you

If it is a third party module create a new directory for it under Modules/third_parties/MyModule#1.0.0
If its a custom javascript file create a new folder under Modules/MyCustomModules/MyModule#1.0.0
Create a JavaScript folder under MyModule#1.0.0/JavaScript and place your file in there.
Create a ns.package.json file at the root of MyModule#1.0.0, with the following contents:
{
"gulp": {
"javascript": [
"JavaScript/*"
]
},
"jshint": "false"
}
Open the distro.json file at the root of the SCA application and add your module to the modules object:
If you added your module to thrid_parties use:
"third_parties/MyModule":"1.0.0"
If you added a new MyCustomModules folder use:
"MyCustomModules/MyModule":"1.0.0"
Then add MyModule to the dependencies object in the distro.json for each application. E.g. if you only use the js file in the shopping application, add it to the dependencies object for the SC.Shopping.Starter entrypoint.
Then gulp deploy to deploy your new module

Related

Azure App Service (Windows) - Nodejs ES Module Problems with SvelteKit app

really hoping someone can point me in the right direction with this one as i'm having no luck at all. I'm trying to host a simple nodejs sveltekit application on a Windows based azure app service, but cannot get the application to start / run.
I'm using the adapter-node adapter for sveltekit to generate the build output as a self contained node app. After sveltekit generates the build output I inject a simple package.json file to the root of the build folder to instruct node to use the ESM style imports which simply contains a single property of type="module".
package.json
{
"type": "module"
}
Lastly I also inject a web.config into the root of the build folder for use with IISNode. The web.config file used is the same as from the nodejs quickstart guide provided by MS. The web.config can be seen here.
The final folder structure of the build output is simply:
build
└───assets
│ └───_app
│ │ ...
└───prerendered
│ index.js
│ package.json
│ web.config
Locally I can take this build folder, place it anywhere on my machine and it runs perfectly by simply running:
node index.js
The Problem
Even though it works perfectly locally, when I deploy the application to the Azure app service the application will not start with the browser simply displaying "This page isn’t working right now".
When I check the logs I see the following error:
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: D:\home\site\wwwroot\index.js
require() of ES modules is not supported.
require() of D:\home\site\wwwroot\index.js from D:\Program Files (x86)\iisnode\interceptor.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from D:\home\site\wwwroot\package.json.
The error tells me that MS's iisnode\interceptor.js is using the commonjs style require syntax and cannot import the ES module of my index.js.
I found someone having a similar problem and a suggested solution here. The suggested solution is to create a new file next to my index.js file and configuring it as the app service's (or more specifically iisnode's) entry point in the web.config. The new file would be named run.cjs and only contain the following:
import("./index.js");
I tried this option, adding the new run.cjs file and updating the web.config to set this as IISNodes entry point:
<add name="iisnode" path="run.cjs" verb="*" modules="iisnode"/>
When I try the site after doing this I get a new problem. The site now loads but instead of seeing the app, the js from index.js renders as raw text into the browser.
The azure app service WEBSITE_NODE_DEFAULT_VERSION is set to ~14 and I can see from Kudu that the version running is 14.16.0 - my local machine is 14.17.0 so the node version looks to be ok.
Can anyone help??
Thanks in advance
Please re-install/update the npm module on your project.
Make sure all these files are present in your project.
Do not import your index.js file in other files like run.cjs or run.mjs, after building your application in your local and publish it in azure app service.
{
"type": "module"
}
This above code is required in the package.json file.
Check your npm reference files, if anyone of them is not installed properly, then you'll get the raw data which is present in app,js file, as output

Is there a way to package an Electron app in order to have an .exe file and just a folder with HTML/JS/CSS files next to it?

I'm using Electron to generate a kind of "website container" for Windows because the users of my app needs to run it locally (they don't always have internet access) but they don't have the possibility to have a web-server on their computer and there are CORS issues if they just open the index.html file directly through the browser.
The Electron generated application is used as container, users are getting their specific files (folder with HTML/CSS/JS files) on github and they put it on the indicated folder in the Electron App. The main.js script in electron only run a Browser window and load the HTML file.
As web application are loading a configuration file modified by the users, they must have access to application files, i can't send them a packaged application.
Currently i'm using Electron-builder with this configuration with "container" folder contains all the website file
"build": {
"appId": "container.app",
"win":{
"target": "portable",
"icon": "favicon.ico",
"asarUnpack": [
"container/**"
]
}
}
This is working fine but there are lots of files in the Electron folder besides the website files:
So it's not really intuitive for users, they have to go to "resources/app.asar.unpacked/container/" folder to update their files.
Isn't their a way to have an ouput like this ?
Have you considered using extraResources in the package.json instead of the unpacked asar? https://www.electron.build/configuration/contents
"build": {
"extraResources": ["./extraResources/**"]
}
That will put your files in the "resources" folder instead, and you can fetch them from your code.

When generating a new project using Vue CLI, how does the app know to look for main.js when bootstrapping

When generating a new project using Vue CLI v.4.0.0 everything is bootstrapped nicely with an index.html file, a couple of .vue files, several configuration files and finally a main.js file. But since the HTML-file does not reference main.js I wonder how Vue knows to look for main.js. Is it implicitly understood by Vue or is there a binding somewhere that tells Vue to look for a file named "main.js"?
Vue CLI runs on Webpack.
Webpack requires an entry file.
You can overwrite the entry file by creating a vue.config.js file at the root of your project and adding:
module.exports = {
configureWebpack: {
entry: {
main: './src/overwritten-main-file.js'
}
}
}
See the Vue.js Configuration Reference for more info

React Builds- Which files go on the server? Why isn't my project deploying?

Goal: I have created the start of a React project and wish to test it on my server (hosted by goDaddy, uploading via cPanel). My app works fine in Development Mode.
Question: I have ran npm build which has created a build folder, but what files am I supposed to upload to my server? I tried putting the entire contents of the build folder on, but it still says the site is not launched. Is this because there is no index.html file generated? Currently my build folder contains: assets.json, LICENSE.txt, package.json, server.js, yarn.lock, chunks/ and public/. Is there supposed to be an html file generated? Or should these files be sufficient to deploy the website given that it works in development mode?
Thanks for bearing with me, this is the first time I have tried to deploy a React App and likely have several fundamental misunderstandings of how it works. Also if anyone is willing to chat for several minutes so I can ask a few questions about my project and react let me know - much appreciated!
Hello
Dear,
If you can try to change your package.json file and add ("homepage": "http://yourDomain/",) like this
"version": "0.1.0",
"homepage": "yourDominUrl",
Like
"homepage": "http://yourDomain/",
and
build again
npm run build
and the build folder is only should be uploaded file
Your answer is much more simple than appears: Just run npm run build, then just upload that whole folder to your GODADDY server. Importantly, you must place your index.html (or app-name.html) directly on the / public path defined by your URL's DNS. So, Top-level has your single entry point index.html that points to folder build/ to get your xyx.main.js and the xyz.main.css ...
and that's it! easy as pie

Require.js r.js: Compile directory to single file

Is there any way to configure RequireJS to compile an entire directory to a single file? I don't mean the normal use case of the 'out' setting. I'll try to explain by example. If I have the following project structure:
- app
- main.js
- menu.js
- module
- file-a.js
- file-b.js
Then let's say I want to compile the 'app' directory to a single file. I don't care about it's dependencies - even if it requires 'module' or either of its files, they won't be included. Even if main.js doesn't require menu.js, it'll be included anyway. The resultant output file would define 'app/main' and 'app/menu' modules.
Likewise, if I wanted to compile the 'module' directory, the file would define 'module/file-a' and 'module/file-b' regardless of what other dependencies were defined.
I hope this is clear enough.
You can use the dir parameter in build file of require instead of just name parameter.
You can read more about building whole directory on requirejs documentation - Optimize Whole Project
If you write build file something like app-build.js-
({
appDir: ".",
baseUrl: "app",
dir: "../app-build",
})
and if you run r.js -o app.build.js then it will create
app-build
main.js
menu.js
Here menu.js will not be include in main.js unless it is required somewhere in main.js source.

Resources