Skip to content

Within psc mangle exports to be compatible with valid ES module exports #2558

@wegry

Description

@wegry

As part of #2207, the issue of name mangling came up in post-processing conversion to ES modules. Currently, exports like on' (the invalid ES character in the identifier) break when converted straight to ES Module export syntax. The name mangler I (and @Pauan concurrently) have written gets around on' becoming on$prime.

This doesn't work well if output object properties (as opposed to exports) have reserved words or apostrophes in them unfortunately. We've had to code around that locally.

As @paf31 has noted, there are tooling concerns for folks using pulp and psci. Improving name mangling has no effect on these tools, but allows folks using JS based bundling a safer way to output smaller code than what psc-bundle currently offers.

Edit: As @michaelficarra has pointed out, the spec does allow reserved words as export names, and @Pauan was recently responsible for patching acorn (which is used by both rollup and webpack) to allow this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions