Skip to content
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

Introduce lazy loading for export expressions #31715

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@squidfunk
Copy link

commented Jun 1, 2019

This PR is meant as a basis for discussion, far from being ready to merge

Currently, CommonJS modules are not exported via Object.defineProperty and lazy getters, but directly via explicit assignments to a file's exports property. This leads to indeterministic behavior when working with re-exports (#12522) and recursive imports (#13245), which are sometimes not necessary.

This is my first PR, so please be nice. The tests don't pass, but before investing a lot of time in fixing them I wanted to discuss whether this approach is viable. I just wanted to go ahead and start a fix on this really, really annoying issue.

It changes this:

"use strict";
var a_1 = require("./a");
exports.a = a_1
var b_1 = require("./b");
exports.b = b_1

To this:

"use strict";
var a_1 = require("./a");
Object.defineProperty(exports, "a", { enumerable: true, get: () => a_1.a });
var b_1 = require("./b");
Object.defineProperty(exports, "b", { enumerable: true, get: () => b_1.b });

My knowledge of the compiler code base is limited. I started successfully using the factory functions for code generation on another project some time ago, but have no knowledge of the transpilation architecture. Happy to collaborate!

@msftclas

This comment has been minimized.

Copy link

commented Jun 1, 2019

CLA assistant check
All CLA requirements met.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.