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

feat(compiler): introduce compile/transform/bundle diagnostics #256

Merged
merged 28 commits into from
May 7, 2018

Conversation

apapko
Copy link
Collaborator

@apapko apapko commented Apr 18, 2018

Details

This PR includes several enhancements to the open source compiler to allow for source code diagnostics and cleaner integration with platform compiler. The open source compiler will be consumed by platform-compiler for transformation and bundling invocation. Furthermore, as part of the effort to minimize compiler maintenance and code/feature duplication, platform-compiler, which in-itself consumes open source compiler, will be now used by both Aura open source and core in the form of a jar ( maven dependency ).

Some details on the changes:

  • Types: everything in the compiler is typed now.
  • Feature based folder structure refactoring
  • More tests coverage
  • Compiler Interface changes
  • Diagnostics

Few remaining TODOS:

  • add real compiler version during build process - PR
  • figure out how to expose all compiler types
  • regenerate expected results in 'amd' format for older tests

Does this PR introduce a breaking change?

  • Yes
  • No

Compiler interface has changed. Aura will now be using platform compiler instead - thus invocation API must be change in Aura to satisfy platform compiler interface - tracked separately.

@apapko apapko added the nomerge label Apr 18, 2018
@apapko apapko requested a review from diervo April 18, 2018 16:41
@salesforce-best-lwc-internal
Copy link

Benchmark comparison

Base commit: 5fd64c2 | Target commit: 1477aa3

benchmark base(5fd64c2) target(1477aa3) trend
table-append-1k.benchmark:benchmark-table/append/1k 253.57 (± 4.26 ms) 270.63 (± 4.36 ms) 👎
table-clear-1k.benchmark:benchmark-table/clear/1k 13.27 (± 0.58 ms) 13.17 (± 0.44 ms) 👌
table-create-10k.benchmark:benchmark-table/create/10k 1486.27 (± 11.85 ms) 1544.91 (± 13.33 ms) 👎
table-create-1k.benchmark:benchmark-table/create/1k 151.89 (± 1.30 ms) 168.25 (± 4.45 ms) 👎
table-update-10th-1k.benchmark:benchmark-table/update-10th/1k 125.43 (± 1.56 ms) 145.37 (± 4.30 ms) 👎
tablecmp-append-1k.benchmark:benchmark-table-component/append/1k 342.05 (± 5.00 ms) 337.50 (± 13.27 ms) 👌
tablecmp-clear-1k.benchmark:benchmark-table/clear/1k 32.67 (± 0.93 ms) 35.20 (± 2.67 ms) 👎
tablecmp-create-10k.benchmark:benchmark-table-component/create/10k 2602.64 (± 37.97 ms) 2385.97 (± 18.80 ms) 👍
tablecmp-create-1k.benchmark:benchmark-table-component/create/1k 278.40 (± 7.35 ms) 263.14 (± 2.99 ms) 👍
tablecmp-update-10th-1k.benchmark:benchmark-table-component/update-10th/1k 116.45 (± 2.00 ms) 143.78 (± 3.53 ms) 👎

@salesforce-best-lwc-internal
Copy link

Benchmark comparison

Base commit: 5fd64c2 | Target commit: fe4ef3f

benchmark base(5fd64c2) target(fe4ef3f) trend
table-append-1k.benchmark:benchmark-table/append/1k 253.57 (± 4.26 ms) 282.40 (± 10.98 ms) 👎
table-clear-1k.benchmark:benchmark-table/clear/1k 13.27 (± 0.58 ms) 14.83 (± 0.82 ms) 👎
table-create-10k.benchmark:benchmark-table/create/10k 1486.27 (± 11.85 ms) 1607.62 (± 44.00 ms) 👎
table-create-1k.benchmark:benchmark-table/create/1k 151.89 (± 1.30 ms) 177.64 (± 6.00 ms) 👎
table-update-10th-1k.benchmark:benchmark-table/update-10th/1k 125.43 (± 1.56 ms) 152.08 (± 3.84 ms) 👎
tablecmp-append-1k.benchmark:benchmark-table-component/append/1k 342.05 (± 5.00 ms) 361.80 (± 15.00 ms) 👎
tablecmp-clear-1k.benchmark:benchmark-table/clear/1k 32.67 (± 0.93 ms) 34.10 (± 1.34 ms) 👎
tablecmp-create-10k.benchmark:benchmark-table-component/create/10k 2602.64 (± 37.97 ms) 2431.45 (± 83.05 ms) 👍
tablecmp-create-1k.benchmark:benchmark-table-component/create/1k 278.40 (± 7.35 ms) 275.76 (± 8.96 ms) 👌
tablecmp-update-10th-1k.benchmark:benchmark-table-component/update-10th/1k 116.45 (± 2.00 ms) 146.88 (± 2.44 ms) 👎

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: 2a5a5ed | Target commit: 081a6a1

lwc-engine-benchmark

table-append-1k metric base(2a5a5ed) target(081a6a1) trend
benchmark-table/append/1k duration 146.50 (± 4.10 ms) 147.60 (± 5.40 ms) -0.75% 👌
table-clear-1k metric base(2a5a5ed) target(081a6a1) trend
benchmark-table/clear/1k duration 11.50 (± 0.50 ms) 11.50 (± 0.40 ms) 0.00% 👌
table-create-10k metric base(2a5a5ed) target(081a6a1) trend
benchmark-table/create/10k duration 842.30 (± 3.50 ms) 842.80 (± 4.80 ms) -0.06% 👌
table-create-1k metric base(2a5a5ed) target(081a6a1) trend
benchmark-table/create/1k duration 100.25 (± 1.70 ms) 101.75 (± 2.35 ms) -1.50% 👎
table-update-10th-1k metric base(2a5a5ed) target(081a6a1) trend
benchmark-table/update-10th/1k duration 89.20 (± 5.00 ms) 88.40 (± 5.10 ms) 0.90% 👌
tablecmp-append-1k metric base(2a5a5ed) target(081a6a1) trend
benchmark-table-component/append/1k duration 244.70 (± 4.50 ms) 242.60 (± 5.70 ms) 0.86% 👌
tablecmp-clear-1k metric base(2a5a5ed) target(081a6a1) trend
benchmark-table/clear/1k duration 31.20 (± 0.70 ms) 30.80 (± 1.50 ms) 1.28% 👌
tablecmp-create-10k metric base(2a5a5ed) target(081a6a1) trend
benchmark-table-component/create/10k duration 1658.70 (± 4.10 ms) 1639.70 (± 4.00 ms) 1.15% 👍
tablecmp-create-1k metric base(2a5a5ed) target(081a6a1) trend
benchmark-table-component/create/1k duration 193.70 (± 4.60 ms) 193.25 (± 3.20 ms) 0.23% 👌
tablecmp-update-10th-1k metric base(2a5a5ed) target(081a6a1) trend
benchmark-table-component/update-10th/1k duration 74.30 (± 5.60 ms) 76.60 (± 4.00 ms) -3.10% 👌

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: 2a5a5ed | Target commit: 1e9e087

lwc-engine-benchmark

table-append-1k metric base(2a5a5ed) target(1e9e087) trend
benchmark-table/append/1k duration 146.50 (± 4.10 ms) 151.80 (± 6.20 ms) -3.62% 👌
table-clear-1k metric base(2a5a5ed) target(1e9e087) trend
benchmark-table/clear/1k duration 11.50 (± 0.50 ms) 11.60 (± 0.50 ms) -0.87% 👌
table-create-10k metric base(2a5a5ed) target(1e9e087) trend
benchmark-table/create/10k duration 842.30 (± 3.50 ms) 843.30 (± 3.30 ms) -0.12% 👌
table-create-1k metric base(2a5a5ed) target(1e9e087) trend
benchmark-table/create/1k duration 100.25 (± 1.70 ms) 100.15 (± 2.25 ms) 0.10% 👌
table-update-10th-1k metric base(2a5a5ed) target(1e9e087) trend
benchmark-table/update-10th/1k duration 89.20 (± 5.00 ms) 85.20 (± 5.00 ms) 4.48% 👌
tablecmp-append-1k metric base(2a5a5ed) target(1e9e087) trend
benchmark-table-component/append/1k duration 244.70 (± 4.50 ms) 245.40 (± 4.10 ms) -0.29% 👌
tablecmp-clear-1k metric base(2a5a5ed) target(1e9e087) trend
benchmark-table/clear/1k duration 31.20 (± 0.70 ms) 32.30 (± 1.00 ms) -3.53% 👎
tablecmp-create-10k metric base(2a5a5ed) target(1e9e087) trend
benchmark-table-component/create/10k duration 1658.70 (± 4.10 ms) 1675.30 (± 8.90 ms) -1.00% 👎
tablecmp-create-1k metric base(2a5a5ed) target(1e9e087) trend
benchmark-table-component/create/1k duration 193.70 (± 4.60 ms) 193.80 (± 5.60 ms) -0.05% 👌
tablecmp-update-10th-1k metric base(2a5a5ed) target(1e9e087) trend
benchmark-table-component/update-10th/1k duration 74.30 (± 5.60 ms) 77.40 (± 3.10 ms) -4.17% 👌

@apapko apapko removed the nomerge label Apr 25, 2018
@apapko apapko requested a review from pmdartus April 25, 2018 14:37
@apapko apapko removed the request for review from diervo April 25, 2018 14:37
* feat(compiler): use real compiler version during build
@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: 2a5a5ed | Target commit: 06c87c4

lwc-engine-benchmark

table-append-1k metric base(2a5a5ed) target(06c87c4) trend
benchmark-table/append/1k duration 146.50 (± 4.10 ms) 142.70 (± 3.80 ms) 2.59% 👌
table-clear-1k metric base(2a5a5ed) target(06c87c4) trend
benchmark-table/clear/1k duration 11.50 (± 0.50 ms) 11.60 (± 0.50 ms) -0.87% 👌
table-create-10k metric base(2a5a5ed) target(06c87c4) trend
benchmark-table/create/10k duration 842.30 (± 3.50 ms) 849.30 (± 3.40 ms) -0.83% 👎
table-create-1k metric base(2a5a5ed) target(06c87c4) trend
benchmark-table/create/1k duration 100.25 (± 1.70 ms) 101.40 (± 1.60 ms) -1.15% 👌
table-update-10th-1k metric base(2a5a5ed) target(06c87c4) trend
benchmark-table/update-10th/1k duration 89.20 (± 5.00 ms) 86.05 (± 4.50 ms) 3.53% 👌
tablecmp-append-1k metric base(2a5a5ed) target(06c87c4) trend
benchmark-table-component/append/1k duration 244.70 (± 4.50 ms) 215.90 (± 15.70 ms) 11.77% 👍
tablecmp-clear-1k metric base(2a5a5ed) target(06c87c4) trend
benchmark-table/clear/1k duration 31.20 (± 0.70 ms) 31.20 (± 0.90 ms) 0.00% 👌
tablecmp-create-10k metric base(2a5a5ed) target(06c87c4) trend
benchmark-table-component/create/10k duration 1658.70 (± 4.10 ms) 1647.40 (± 8.20 ms) 0.68% 👍
tablecmp-create-1k metric base(2a5a5ed) target(06c87c4) trend
benchmark-table-component/create/1k duration 193.70 (± 4.60 ms) 197.30 (± 3.80 ms) -1.86% 👌
tablecmp-update-10th-1k metric base(2a5a5ed) target(06c87c4) trend
benchmark-table-component/update-10th/1k duration 74.30 (± 5.60 ms) 75.10 (± 4.20 ms) -1.08% 👌

package.json Outdated
]
],
"dependencies": {
"source-map": "^0.7.2"
Copy link
Member

Choose a reason for hiding this comment

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

Remove root level dependency

"@types/babel-core": "^6.25.3",
"@types/chokidar": "^1.7.5",
"magic-string": "^0.22.4",
"source-map": "^0.7.2",
Copy link
Member

Choose a reason for hiding this comment

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

Where is it used?

@@ -29,6 +30,10 @@
"rollup-plugin-replace": "^2.0.0"
},
"devDependencies": {
"@types/babel-core": "^6.25.3",
"@types/chokidar": "^1.7.5",
"magic-string": "^0.22.4",
Copy link
Member

Choose a reason for hiding this comment

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

Where is it used?

@@ -29,6 +30,10 @@
"rollup-plugin-replace": "^2.0.0"
},
"devDependencies": {
"@types/babel-core": "^6.25.3",
"@types/chokidar": "^1.7.5",
Copy link
Member

Choose a reason for hiding this comment

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

Where is it used?

const { version } = require("../package.json");

async function updateVersion(version) {
const inputPath = (outputPath = path.resolve("dist/commonjs/index.js"));
Copy link
Member

Choose a reason for hiding this comment

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

No single line assignment. This will not work if this file is in strict mode.

// split result: ["'x-bar', 'x-foo'"]
const imports = rawImports.split(/,\s*/) || [];

imports.forEach(moduleImport => {
Copy link
Member

Choose a reason for hiding this comment

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

A good old Array.prototype.map would do the trick here instead of a Array.prototype.forEach. This way the callback can become pure.

files: BundleFiles;
outputConfig?: OutputConfig;

// TODO: below must be removed after lwc-compiler consumers change
Copy link
Member

Choose a reason for hiding this comment

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

Still needed?

});
const result = babel.transform(code, config);

if (!result || !result.code) {
Copy link
Member

Choose a reason for hiding this comment

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

When is it the case?
I would like to have a more explicit error when babel doesn't return any code.

src: string,
filename: string,
{ outputConfig }: NormalizedCompilerOptions,
metadataCollector?: MetadataCollector,
Copy link
Member

Choose a reason for hiding this comment

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

Remove unused param

src: string,
filename: string,
options: NormalizedCompilerOptions,
metadataCollector?: MetadataCollector
Copy link
Member

Choose a reason for hiding this comment

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

Remove used param

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: 2a5a5ed | Target commit: b004f3c

lwc-engine-benchmark

table-append-1k metric base(2a5a5ed) target(b004f3c) trend
benchmark-table/append/1k duration 146.50 (± 4.10 ms) 144.30 (± 3.70 ms) 1.50% 👌
table-clear-1k metric base(2a5a5ed) target(b004f3c) trend
benchmark-table/clear/1k duration 11.50 (± 0.50 ms) 11.70 (± 0.50 ms) -1.74% 👎
table-create-10k metric base(2a5a5ed) target(b004f3c) trend
benchmark-table/create/10k duration 842.30 (± 3.50 ms) 840.50 (± 7.30 ms) 0.21% 👌
table-create-1k metric base(2a5a5ed) target(b004f3c) trend
benchmark-table/create/1k duration 100.25 (± 1.70 ms) 99.30 (± 2.10 ms) 0.95% 👌
table-update-10th-1k metric base(2a5a5ed) target(b004f3c) trend
benchmark-table/update-10th/1k duration 89.20 (± 5.00 ms) 90.10 (± 5.10 ms) -1.01% 👌
tablecmp-append-1k metric base(2a5a5ed) target(b004f3c) trend
benchmark-table-component/append/1k duration 244.70 (± 4.50 ms) 239.00 (± 7.40 ms) 2.33% 👍
tablecmp-clear-1k metric base(2a5a5ed) target(b004f3c) trend
benchmark-table/clear/1k duration 31.20 (± 0.70 ms) 32.35 (± 1.00 ms) -3.69% 👎
tablecmp-create-10k metric base(2a5a5ed) target(b004f3c) trend
benchmark-table-component/create/10k duration 1658.70 (± 4.10 ms) 1673.00 (± 6.30 ms) -0.86% 👎
tablecmp-create-1k metric base(2a5a5ed) target(b004f3c) trend
benchmark-table-component/create/1k duration 193.70 (± 4.60 ms) 194.30 (± 2.50 ms) -0.31% 👌
tablecmp-update-10th-1k metric base(2a5a5ed) target(b004f3c) trend
benchmark-table-component/update-10th/1k duration 74.30 (± 5.60 ms) 73.40 (± 5.10 ms) 1.21% 👌

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: 2a5a5ed | Target commit: 3efd4fa

lwc-engine-benchmark

table-append-1k metric base(2a5a5ed) target(3efd4fa) trend
benchmark-table/append/1k duration 146.50 (± 4.10 ms) 163.00 (± 7.00 ms) -11.26% 👎
table-clear-1k metric base(2a5a5ed) target(3efd4fa) trend
benchmark-table/clear/1k duration 11.50 (± 0.50 ms) 13.20 (± 0.40 ms) -14.78% 👎
table-create-10k metric base(2a5a5ed) target(3efd4fa) trend
benchmark-table/create/10k duration 842.30 (± 3.50 ms) 879.80 (± 12.00 ms) -4.45% 👎
table-create-1k metric base(2a5a5ed) target(3efd4fa) trend
benchmark-table/create/1k duration 100.25 (± 1.70 ms) 105.05 (± 2.25 ms) -4.79% 👎
table-update-10th-1k metric base(2a5a5ed) target(3efd4fa) trend
benchmark-table/update-10th/1k duration 89.20 (± 5.00 ms) 96.90 (± 3.30 ms) -8.63% 👎
tablecmp-append-1k metric base(2a5a5ed) target(3efd4fa) trend
benchmark-table-component/append/1k duration 244.70 (± 4.50 ms) 270.90 (± 3.70 ms) -10.71% 👎
tablecmp-clear-1k metric base(2a5a5ed) target(3efd4fa) trend
benchmark-table/clear/1k duration 31.20 (± 0.70 ms) 34.90 (± 1.60 ms) -11.86% 👎
tablecmp-create-10k metric base(2a5a5ed) target(3efd4fa) trend
benchmark-table-component/create/10k duration 1658.70 (± 4.10 ms) 1763.70 (± 7.70 ms) -6.33% 👎
tablecmp-create-1k metric base(2a5a5ed) target(3efd4fa) trend
benchmark-table-component/create/1k duration 193.70 (± 4.60 ms) 205.75 (± 4.45 ms) -6.22% 👎
tablecmp-update-10th-1k metric base(2a5a5ed) target(3efd4fa) trend
benchmark-table-component/update-10th/1k duration 74.30 (± 5.60 ms) 77.90 (± 3.50 ms) -4.85% 👎

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: 2a5a5ed | Target commit: 99b3d57

lwc-engine-benchmark

table-append-1k metric base(2a5a5ed) target(99b3d57) trend
benchmark-table/append/1k duration 146.50 (± 4.10 ms) 154.50 (± 4.40 ms) -5.46% 👎
table-clear-1k metric base(2a5a5ed) target(99b3d57) trend
benchmark-table/clear/1k duration 11.50 (± 0.50 ms) 12.50 (± 0.40 ms) -8.70% 👎
table-create-10k metric base(2a5a5ed) target(99b3d57) trend
benchmark-table/create/10k duration 842.30 (± 3.50 ms) 883.50 (± 11.00 ms) -4.89% 👎
table-create-1k metric base(2a5a5ed) target(99b3d57) trend
benchmark-table/create/1k duration 100.25 (± 1.70 ms) 106.10 (± 2.30 ms) -5.84% 👎
table-update-10th-1k metric base(2a5a5ed) target(99b3d57) trend
benchmark-table/update-10th/1k duration 89.20 (± 5.00 ms) 97.00 (± 3.80 ms) -8.74% 👎
tablecmp-append-1k metric base(2a5a5ed) target(99b3d57) trend
benchmark-table-component/append/1k duration 244.70 (± 4.50 ms) 257.90 (± 4.70 ms) -5.39% 👎
tablecmp-clear-1k metric base(2a5a5ed) target(99b3d57) trend
benchmark-table/clear/1k duration 31.20 (± 0.70 ms) 34.60 (± 1.00 ms) -10.90% 👎
tablecmp-create-10k metric base(2a5a5ed) target(99b3d57) trend
benchmark-table-component/create/10k duration 1658.70 (± 4.10 ms) 1732.00 (± 12.40 ms) -4.42% 👎
tablecmp-create-1k metric base(2a5a5ed) target(99b3d57) trend
benchmark-table-component/create/1k duration 193.70 (± 4.60 ms) 199.30 (± 3.10 ms) -2.89% 👎
tablecmp-update-10th-1k metric base(2a5a5ed) target(99b3d57) trend
benchmark-table-component/update-10th/1k duration 74.30 (± 5.60 ms) 77.90 (± 4.70 ms) -4.85% 👌

@apapko
Copy link
Collaborator Author

apapko commented May 4, 2018

@caridy @pmdartus please review


describe("compiler options", () => {
it("should validate presence of options", async () => {
expect.assertions(1);
Copy link
Member

Choose a reason for hiding this comment

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

Remove the expect.assertion(1). Not needed anymore.

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: 2a5a5ed | Target commit: b8792c0

lwc-engine-benchmark

table-append-1k metric base(2a5a5ed) target(b8792c0) trend
benchmark-table/append/1k duration 146.50 (± 4.10 ms) 145.80 (± 3.50 ms) 0.48% 👌
table-clear-1k metric base(2a5a5ed) target(b8792c0) trend
benchmark-table/clear/1k duration 11.50 (± 0.50 ms) 11.60 (± 0.50 ms) -0.87% 👌
table-create-10k metric base(2a5a5ed) target(b8792c0) trend
benchmark-table/create/10k duration 842.30 (± 3.50 ms) 852.50 (± 7.90 ms) -1.21% 👎
table-create-1k metric base(2a5a5ed) target(b8792c0) trend
benchmark-table/create/1k duration 100.25 (± 1.70 ms) 101.50 (± 2.00 ms) -1.25% 👎
table-update-10th-1k metric base(2a5a5ed) target(b8792c0) trend
benchmark-table/update-10th/1k duration 89.20 (± 5.00 ms) 94.60 (± 3.00 ms) -6.05% 👌
tablecmp-append-1k metric base(2a5a5ed) target(b8792c0) trend
benchmark-table-component/append/1k duration 244.70 (± 4.50 ms) 245.90 (± 6.10 ms) -0.49% 👌
tablecmp-clear-1k metric base(2a5a5ed) target(b8792c0) trend
benchmark-table/clear/1k duration 31.20 (± 0.70 ms) 31.40 (± 1.30 ms) -0.64% 👌
tablecmp-create-10k metric base(2a5a5ed) target(b8792c0) trend
benchmark-table-component/create/10k duration 1658.70 (± 4.10 ms) 1700.90 (± 7.30 ms) -2.54% 👎
tablecmp-create-1k metric base(2a5a5ed) target(b8792c0) trend
benchmark-table-component/create/1k duration 193.70 (± 4.60 ms) 195.10 (± 2.40 ms) -0.72% 👌
tablecmp-update-10th-1k metric base(2a5a5ed) target(b8792c0) trend
benchmark-table-component/update-10th/1k duration 74.30 (± 5.60 ms) 77.30 (± 2.30 ms) -4.04% 👌

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.

2 participants