netsuite-suitecloud-sdk icon indicating copy to clipboard operation
netsuite-suitecloud-sdk copied to clipboard

[FR] Add compatiblity with transpilers.

Open gabrielgortabns opened this issue 2 years ago • 2 comments

Let say, I have transpiler, that transform some code in ./src/ directory to other code in ./build/ directory. It would be nice, to be able to trigger upload from ./src/ directory, that would upload transpiled version of code.

Possible solution:

Configuration/setting where user can specify that if they trigger upload in ./src/FileCabined/SuiteScripts/sample.ts it will upload ./build/FileCabined/SuiteScripts/sample.js... it could be defined via regex, or syntax like:

{
    "source": ["src/**/*.ts", "src/**/*.js"]
    "build": ["build/**/*.js"]
}

or function:

function pathUpdate(path) {
    return path.replace(/^build/, "src").replace(/.ts$/, ".js");
}

that can be part of suitecloud.config.js.

gabrielgortabns avatar Feb 03 '23 08:02 gabrielgortabns

Have you tried doing this via the tsconfig file? Create a base tsconfig.json then create your separate build ones

  "extends": "./tsconfig.json",
  "compilerOptions": {
	"paths": {
      "N": ["node_modules/@hitc/netsuite-types/N"],
      "N/*": ["node_modules/@hitc/netsuite-types/N/*"],
      "SuiteScripts/*": ["../SuiteScripts/*"]
    },
	"outDir": "./src/FileCabinet/SuiteScripts",
  },
  "exclude": [
	"node_modules",
        ... Other files/folders exclude from this build
   ]

then in your package file something like

    "build": "npm run build-scripts && npm run build-test",
    "build-scripts": "tsc -p tsconfig.build.json",
    "build-test": "tsc -p tsconfig.tests.json",

Rvice avatar Feb 09 '23 18:02 Rvice

yes but the issue is that while source files are in ./src/ files, and build files are in ./build/, I want to be able to execute for example command suitecloud.uploadfile without need to opening ./build/ folder (those are two different folders, but even if, I still can't execute upload in .ts file, bcs it would upload that TS file, not compiled JS version). RN, I must navigate to ./build/ as in ./src/ it throws error:

The file to upload should be in a supported folder inside the FileCabinet folder. For information about the supported folders, see https://system.netsuite.com/app/help/helpcenter.nl?fid=section_4724963992.html.

also this doesn't help, as in my case, I also change some other parts of path to file.

gabrielgortabns avatar Feb 13 '23 09:02 gabrielgortabns