Build succeeds but I do…
Build succeeds, but I do get runtime errors
Responses:
what are the runtime errors?
You can also just rename them as .ts
since all js is valid ts
SyntaxError: Unexpected token export
I guess the js
files are not transpiled
yup you are right
you can probably edit your tsconfig to include js files alongside ts files
Isn’t it just like changing js
to ts
?
(would mostly save me the time of actually doing it file by file)
It will accomplish the same task but are different ways to go about it.
But this leaves the issue that once changed to ts
I get lots of reds (e.g. TS errors)
you are probably better off including js files in the build
Ok - seems to magically work again :slightly_smiling_face:
Yup! Cause you are telling the typescript compiler to compile the js files alongside your ts files (which it knows how to do)
React or Angular? Nx has options to generate JavaScript for React apps and libs. If you’re using React, try these commands out to see how Nx sets up your workspace to support JavaScript: https://nx.dev/react/guides/js-and-ts
"allowJs": true
is probably already set in your project’s tsconfig.json
. What needs to happen is that **/*.js
and **/*.jsx
needs to be added to the include
option of your project’s tsconfig.json
.
Sample tsconfig.json
for a React JavaScript project
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"jsx": "react",
"allowJs": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"types": ["node", "jest"]
},
"files": [
"../../node_modules/@nrwl/react/typings/cssmodule.d.ts",
"../../node_modules/@nrwl/react/typings/image.d.ts"
],
"include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"]
}
For Angular, you might also be able to set "allowJs": true
and add **/*.js
to the include
option.
Hi. Thanks a lot. I’m currently only moving the microservices and pure nodejs/helper libraries. The UI will be more complex to move, so it’s like phase 2 :slightly_smiling_face: