Skip to content

[QUESTION] main.tns.ts is missing from the TypeScript compilation Nativescript / Angular + Nativescript/webpack Shared project. #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pandabuilt opened this issue Aug 19, 2021 · 2 comments

Comments

@pandabuilt
Copy link

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 8.0.2
  • Cross-platform modules:
  • Android Runtime:
  • iOS Runtime:
  • Plugin(s):
  • NativeScript-Angular: "@nativescript/angular": "~12.0.0",
  • Angular: "@angular/core": "~12.1.4",

Describe the bug
How do we move forward with a tsconfig.app.json file for web (angular.json) and a tsconfig.tns.json file for Nativescript?

in a @nativescript/schematics project we had a tsconfig.json and a tsconfig.tns.json file. Inside the webpack.config.js file we had several lines where they mapped the tsconfig file based on the one in the angular.json file to the tns.json file to the env.json file and it would use the most detailed one by default.

in Nativescript/Webpack 5 beta we can see it points us to use TsconfigPathsPlugin

So I still have the tsconfig json file for angular web. This includes main.ts, polyfills.ts, etc. However, when I run the app vis ns debug - it uses the tsconfig.json file from angular.json. Okay, so I figured I needed to update the new webpack.config file to tell it what one to use. I see it tells me to add 'TsconfigPathsPlugin' based on the docs. However, I added the code below to my config file and it's still using the other tsConfig.app.js file

const webpack = require('@nativescript/webpack');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');

module.exports = env => {
webpack.init(env)
webpack.useConfig('angular');

webpack.chainWebpack(config => {
config.resolve.plugin('TsconfigPathsPlugin').use(
new TsconfigPathsPlugin({
configFile: './tsconfig.tns.json',
logLevel: "info",
})
)
});

return webpack.resolveConfig();
}

@pandabuilt
Copy link
Author

@edusperoni
Copy link
Collaborator

We're moving away from code sharing with nativescript schematics and focusing on nx instead, you can read a detailed rundown of the reasons here:
NativeScript/nativescript-angular#2290 (comment)

You can try to make it work, but it's not something we're officially supporting going forward. If you REALLY want to make it work you probably need to:

  • tap into the AngularCompilerPlugin/AngularWebpackPlugin constructor (using webpack chain) and change the tsconfig file
  • prepend the tns prefix to the resolver.extension

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants