Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Proposal] Packing should produce dist folder and not pollute src folder with .js files #154

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

Open
VladimirAmiorkov opened this issue Jul 11, 2019 · 3 comments
Labels

Comments

@VladimirAmiorkov
Copy link

Please, provide the following version numbers that your issue occurs with:

  • CLI: (run tns --version to fetch it) 6.0.0
  • Cross-platform modules: (check the 'version' attribute in the 6.0.0
    node_modules/tns-core-modules/package.json file in your project)
  • Runtime(s): 6.0.0

Please, tell us how to recreate the issue in as much detail as possible.

Currently the seed structure has npm scripts that will trigger 'tsc' inside the src folder which will produce JavaScript files in it. With NativeScript 6.0.0 any symlinked plugin should not contain both TypeScript and JavaScript files because this can make webpack work unexpectedly.

@VladimirAmiorkov VladimirAmiorkov changed the title Packing should produce dist folder and not pollute src folder with .js files [Proposal] Packing should produce dist folder and not pollute src folder with .js files Jul 11, 2019
@manijak
Copy link

manijak commented Jul 21, 2019

You can do this already today. Just need to add a few npm scripts to your package.json.
Take a look on how I did it for my Carousel plugin: https://github.com/manijak/nativescript-carousel/blob/master/src/package.json

"tsc": "tsc -skipLibCheck --outDir dist",
"tsc.dist": "npm run dist.clean && tsc -skipLibCheck --outDir dist && npm run dist.copy",
"dist.copy": "cp -R platforms dist && cp ../README.md dist && cp carousel.d.ts dist && cp package.json dist",
"dist.clean": "rimraf dist",
"plugin.tscwatch": "npm run tsc -- -w",

The only thing I've noticed is that watch & HMR only apply the first change, not the later ones. Even tho it detects them and reports that they have been synced.

@PeterStaev
Copy link

This one major drawback of the seed. And this is why I use grunt to build my plugins TS to JS, having gazzilions copy scripts in the package.json is not that appealing...

@PeterStaev
Copy link

I think I made this work w/o those copy scripts:

  • Set the tsconfig.json to output the compiled JS in dist folder
  • Change package.json file to point the main entry to dist/<your-plugin-name
  • Add a script to run tsc in watch mode for the src folder.

This way when you make a change the watch will replace the files in the dist folder. And since the main points to that file it triggers HMR to update the app.

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

No branches or pull requests

4 participants