microsoft / rushstack

Monorepo for tools developed by the Rush Stack community
https://rushstack.io/
Other
5.95k stars 602 forks source link

[heft] "additionalModuleKindsToEmit" does not include source maps or static assets #2066

Open octogonz opened 4 years ago

octogonz commented 4 years ago

Please prefix the issue title with the project name i.e. [rush], [api-extractor] etc.

Is this a feature or a bug?

Please describe the actual behavior.

Add a typescript.json config file that specifies additionalModuleKindsToEmit. For example:

.heft/typescript.json

/**
 * Configures the TypeScript plugin for Heft.  This plugin also manages linting.
 */
 {
  "$schema": "https://developer.microsoft.com/json-schemas/heft/typescript.schema.json",

  /**
   * If provided, emit these module kinds in addition to the modules specified in the tsconfig.
   * Note that this option only applies to the main tsconfig.json configuration.
   */
  "additionalModuleKindsToEmit": [
    // {
    //   /**
    //    * (Required) Must be one of "commonjs", "amd", "umd", "system", "es2015", "esnext"
    //    */
    //  "moduleKind": "amd",
    //
    //   /**
    //    * (Required) The path where the output will be written.
    //    */
    //    "outFolderPath": "lib-amd"
    // }
    {
      "moduleKind": "commonjs",
      "outFolderPath": "lib-commonjs"
    }
  ],
}

Also, configure copy-static-assets.json to copy .css files, for example:

.heft/copy-static-assets.json

{
  "$schema": "https://developer.microsoft.com/json-schemas/heft/copy-static-assets.schema.json",

  /**
   * File extensions that should be copied from the src folder to the destination folder(s).
   */
  "fileExtensions": [
    ".css"
  ]
}

What is the expected behavior?

The two output folders (my-project/lib and my-project/lib-commonjs) should both have .js.map files and copied .css files.

Instead, only my-project/lib has these files.

If this is a bug, please provide the tool version, Node.js version, and OS.

Tool: Heft version 0.3.1

CC @iclanton

jasonswearingen commented 4 years ago

related: https://github.com/microsoft/rushstack/issues/2141#issuecomment-684101858

dmichon-msft commented 4 years ago

This is currently by design, as source map generation is very expensive, and having multiple copies of .d.ts files, source maps, etc. massively bloats package sizes. This sounds more like a feature request to allow them this to be configurable.