nx
nx copied to clipboard
add "outputFileName" to @nx/js:tsc schema
Documentation issue
- [ ] Reporting a typo
- [ ] Reporting a documentation bug
- [x] Documentation improvement
- [ ] Documentation feedback
Is there a specific documentation page you are reporting?
https://nx.dev/packages/js/executors/tsc
Additional context or description
Missing docs for custom entry point file when using an executor like @nx/js:node. The executor looks for main.js in the dist folder. To override, must use outputFileName option in tsc executor (for instance if entrypoint file is src/main.js)
Fix is merged here. Docs need to be updated to reflect
https://github.com/nrwl/nx/pull/17266#issuecomment-1565406622
I am not sure if you want me to create a new issue, however, outputFileName is also missing in [email protected]/schemas/project-schema.json.
When it is not set in apps/app/project.json, anytime I run nx serve app (which runs either app:serve:production or app:serve:development), I get a warning that is is not set for the app and that it uses the fallback value of dist/apps/app/main.js.
When I set it in apps/app/project.json, I get an error that outputFileName is not found in schema.
Update
I’ve tried to update project-schema.json (L37-43), however, that did not fix the issue (I still get an error the error of not found outputFileName). I have those lines to this code snippet:
"configurations": {
"type": "object",
"description": "provides extra sets of values that will be merged into the options map",
"additionalProperties": {
"type": "object",
"properties": {
"outputFileName": {
"type": "string",
"description": "The name with path when compiled project file should be saved"
}
}
}
},
Basically, I have defined the missing property. I have used this online schema validator and it says the schema is valid. Bellow is the project.json contents I tried to use.
project.json
{
"name": "app",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/app/src",
"projectType": "application",
"targets": {
"serve": {
"executor": "@nx/js:node",
"defaultConfiguration": "development",
"options": {
"buildTarget": "app:build"
},
"configurations": {
"development": {
"buildTarget": "app:build:development",
"outputFileName": "../../dist/dev/apps/app/main.js"
},
"production": {
"buildTarget": "app:build:production",
"outputFileName": "../../dist/apps/app/main.js"
}
}
}
},
"tags": []
}
Then, I went and updated all configurations properties in all three schemas in that folder (nx-schema.json, project-schema.json and workspace-schema.json) in the very same matter; there where four instances only, however, even that did not fix this issue. I believe, Nx ignores that outputFileName property somewhere else, regardless whether it is defined in the schema or not.
Actually, at first, I tried to add outputFileName to the app’s webpack.config.js, however, neither that fixed the issue. Bellow is the config I have tried.
webpack.config.js
const {join} = require('node:path')
const {NxWebpackPlugin} = require('@nx/webpack')
module.exports = {
output: {
path: join(__dirname, '../../dist/apps/app')
},
plugins: [
new NxWebpackPlugin({
assets: ['./src/assets'],
compiler: 'tsc',
main: './src/main.ts',
optimization: false,
outputFileName: '../../dist/apps/app/main.js',
outputHashing: 'none',
target: 'node',
tsConfig: './tsconfig.app.json'
})
]
}
@tukusejssirs I have the exact same problem, tried to fix it just like you did. Justed wanted to chime in and confirm the behavior.