Skip to content

Include a compiler option to omit export statements in Javascript output. #46876

Closed
@bdcoder2

Description

@bdcoder2

I am very green with regard to Typescript (as I have only started converting our Javascript codebase), but have been "bitten" by the same problem described in Issue 41513.

I initially posted a similar question on StackOverflow, and found my own (not-very-elegant) solution.

What I (and apparently others) would really like to see is a compiler switch such as:

tsc --noGeneratedExports

Regardless of the compiler option / switch name, the effect would be that tsc would NOT emit statements such as the following (which appear at the top of a Javascript file):

Object.defineProperty(exports, "__esModule", { value: true });

... or the following, which appear at the end of a Javascript file:

export {};

In both cases above, when trying to load the resulting Javascript LOCALLY (from the file system) -- the browser will throw an exception.

Having a compiler option that outputs Javascript that can be loaded into a browser locally would eliminate the need for a module bundler and/or local web server.

Thanks in advance for your consideration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    UnactionableThere isn't something we can do with this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions