I have a shared web/nativescript library. All nativescript files have a **/*.tns.ts filename format. Nativescript handles replacing any file with the same name but without the tns part with its tns counterpart. Thus if there is no tns counterpart it uses the same file as the web version. When I'm trying to build the library for the web the resulting code is free of nativescript code because the import chain is sure to not see any *.tns.ts. However, ng-packagr sees those files because it adds all imports in them as peerDependencies to the resulting package.json file even though there is no mention of those libraries in the resulting packaged code.
So my question is can I configure ng-packagr to also follow the chain of imports or skip some files for determining dependencies. I've tried setting adding **/*.tns.ts to my exclude list in my tsconfig.json with no luck.
Here is my ng-package.json file ...
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/libs/core",
"lib": {
"entryFile": "src/index.ts",
"styleIncludePaths": ["./node_modules"]
}
}
I'm using nx to build and here is my relevant project.json ...
{
"name": "core",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "library",
"sourceRoot": "libs/core/src",
"prefix": "animalus",
"targets": {
"build": {
"executor": "@nx/angular:ng-packagr-lite",
"outputs": ["{workspaceRoot}/dist/libs/core"],
"options": {
"tsConfig": "libs/core/tsconfig.lib.json",
"project": "libs/core/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "libs/core/tsconfig.lib.prod.json"
},
"development": {
"tsConfig": "libs/core/tsconfig.lib.json"
}
},
"defaultConfiguration": "production"
},
"test": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "libs/core/jest.config.ts",
"passWithNoTests": true
}
}
},
"generators": {
"@schematics/angular:component": {
"style": "scss"
}
},
"tags": []
}
Relevant versions:
"@nx/angular": "16.3.2",
"ng-packagr": "^15.2.2",