Skip to content

Alternative bundling#750

Merged
Perryvw merged 19 commits intomasterfrom
feature/bundling-v2
Nov 30, 2019
Merged

Alternative bundling#750
Perryvw merged 19 commits intomasterfrom
feature/bundling-v2

Conversation

@Perryvw
Copy link
Copy Markdown
Member

@Perryvw Perryvw commented Nov 17, 2019

Alternative approach to bundling from #648 and #747.

Took test cases from #648.

Instead of using outFile, instead uses luaBundle and luaBundleEntry tstl options.

…in bundling. Added diagnostics and more tests
public expectToHaveDiagnostics(): this {
expect(this.getLuaDiagnostics()).toHaveDiagnostics();
public expectToHaveDiagnostic(matcher: DiagnosticMatcher): this {
expect(this.getLuaDiagnostics().find(matcher)).toBeDefined();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that really something we'd need that often to add a new method there?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't really have an alternative if we don't want to specify the exact diagnostic each time (which looks really messy and is not really required imo).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather use diagnostic codes for that. In the future we should probably use an enum, or copy TypeScript's diagnostic messages concept to avoid magic numbers.

public expectToHaveDiagnostics(): this {
expect(this.getLuaDiagnostics()).toHaveDiagnostics();
public expectToHaveDiagnostic(matcher: DiagnosticMatcher): this {
expect(this.getLuaDiagnostics().find(matcher)).toBeDefined();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather use diagnostic codes for that. In the future we should probably use an enum, or copy TypeScript's diagnostic messages concept to avoid magic numbers.


type CommandLineOption = CommandLineOptionOfEnum | CommandLineOptionOfBoolean;
interface CommandLineOptionOfString extends CommandLineOptionBase {
type: "string";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…ePath and rootDir, addressed other PR comments
src/bundle.ts Outdated
const diagnostics: ts.Diagnostic[] = [];

const resolvedEntryModule = resolveFromRootDir(program, entryModule);
if (!transpiledFiles.some(f => resolveFromRootDir(program, f.fileName) === resolvedEntryModule)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is resolveFromRootDir required? Isn't fileName always resolved and normalized?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think it is when you manually construct the program (like we do in our tests)

@@ -0,0 +1,18 @@
import * as path from "path";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have few tests with tsconfig.json in CLI, but yeah, we don't have any tests using transpileProject API. Maybe at least we may reduce scope of that test? I.e. rename it to project and remove that imaginary host API (which we already test)?

Copy link
Copy Markdown
Contributor

@ark120202 ark120202 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than these 3 small notes LGTM. There are still few unresolved things but I'm fine with doing them in follow-up PRs

@Perryvw Perryvw marked this pull request as ready for review November 29, 2019 19:07
@Perryvw Perryvw changed the title [WIP] Alternative bundling Alternative bundling Nov 29, 2019
@Perryvw Perryvw force-pushed the feature/bundling-v2 branch from 7fc3b28 to 5003460 Compare November 29, 2019 19:22
@Perryvw Perryvw merged commit d88c930 into master Nov 30, 2019
@Perryvw Perryvw deleted the feature/bundling-v2 branch November 30, 2019 15:53
@Perryvw Perryvw mentioned this pull request Nov 30, 2019
5 tasks
@ark120202 ark120202 mentioned this pull request Dec 1, 2019
const requireOverride = `
local ____moduleCache = {}
local ____originalRequire = require
function require(file)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, is there a specific reason for this not being local? It would still equivalently be used by the whole file, but with the benefit of not leaking outside this file

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No specific reason, we did not consider this at all. I think it is indeed a good idea to make this adjustment.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in #757

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants