Skip to content

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

Open

Description

@VladimirAmiorkov

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.

Activity

  1. 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[/+] on Jul 11, 2019
  2. manijak commented on Jul 21, 2019

    @manijak

    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.

  3. PeterStaev commented on Aug 15, 2019

    @PeterStaev

    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...

  4. PeterStaev commented on Aug 18, 2019

    @PeterStaev

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions