-
Notifications
You must be signed in to change notification settings - Fork 439
@W-20806053 Implement Private Methods #5711
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
Open
a-chabot
wants to merge
32
commits into
salesforce:master
Choose a base branch
from
a-chabot:a-chabot/private-methods-transform
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+826
−45
Open
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
bea64c5
feat: first attempt
a-chabot f443394
fix: linter fix
a-chabot 2d9ad36
fix: update note
a-chabot 999c686
fix: cleaning up lint errors to be able to run tests
a-chabot 6b1f599
fix: bump "Next error code" comment to 1213
a-chabot 4b1e630
feat: add round-trip validation for private method transforms
a-chabot 8dcb515
test: add full-cycle and intermediate disruption tests for private me…
a-chabot 9b1e109
refactor: make PRIVATE_METHOD_NAME_COLLISION error message mention re…
a-chabot 61ad8b5
chore: revert playground counter.js to master
a-chabot 76da7ac
refactor: hoist methodKind constant to module scope
a-chabot fcf9c25
refactor: extract shared copyMethodMetadata helper for private method…
a-chabot c409872
refactor: make forward and reverse private method transforms independ…
a-chabot 591bc67
refactor: move non-null assertion to transformSync helpers in tests
a-chabot a2d3e4b
refactor: consolidate fragmented toContain assertions in tests
a-chabot 7e51945
test: add test cases for private fields passing through unchanged
a-chabot d4f93e4
test: add test cases for rogue #privateNames not sneaking through
a-chabot f284247
feat: add unsupported private member errors and fixture e2e tests
a-chabot 380c24d
chore: retrigger CI
a-chabot f18b317
feat: transform private method invocations in forward and reverse passes
a-chabot 3461010
feat: gate private method transform behind enablePrivateMethods compi…
a-chabot 2ba8959
feat: thread enablePrivateMethods through rollup plugin and enable in…
a-chabot d38ae20
chore: revert playground counter and rollup config changes
a-chabot c59f08a
Merge pull request #1 from a-chabot/a-chabot/private-methods-compiler…
a-chabot 446b34a
test: move private-methods fixture tests to dedicated branch
a-chabot 197d2ff
test: remove inline tests now covered by fixture tests
a-chabot f024518
test: remove inline tests now covered by fixture tests
a-chabot 4d60549
test: replace per-test comments with top-of-file blurb
a-chabot 500c3b3
test: add cross-class private method access inline tests
a-chabot e49f1b3
docs: add enablePrivateMethods to rollup plugin README
a-chabot 2820b37
docs: add enablePrivateMethods to compiler README
a-chabot cb1870d
test: skip empty private-methods fixtures suite until tests are merged
a-chabot c2a8c07
Merge remote-tracking branch 'origin/master' into a-chabot/private-me…
a-chabot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,44 +1,42 @@ | ||
| global: | ||
| email-reply-to: raptorteam@salesforce.com | ||
| preprocessor-tag: jenkins-sfci-sfci-managed-preprocessor-PR-6322-40-itest | ||
|
|
||
| email-reply-to: raptorteam@salesforce.com | ||
| preprocessor-tag: jenkins-sfci-sfci-managed-preprocessor-PR-6322-40-itest | ||
|
|
||
| stages: | ||
| build: | ||
| - npm-setup: | ||
| yarn-modern: true | ||
| - step: | ||
| name: yarn-build | ||
| image: docker.repo.local.sfdc.net/sfci/docker-images/sfdc_rhel9_nodejs20/sfdc_rhel9_nodejs20_build:latest | ||
| commands: | ||
| - yarn install | ||
| - yarn build | ||
| - yarn test | ||
| integration-test: | ||
| - downstream-dependency: | ||
| downstream-repos: | ||
| - repo-url: https://github.com/salesforce-experience-platform-emu/lwc-platform | ||
| branches: | ||
| - master | ||
| packages-to-test: | ||
| npm: | ||
| - "@lwc/aria-reflection" | ||
| - "@lwc/babel-plugin-component" | ||
| - "@lwc/compiler" | ||
| - "@lwc/engine-core" | ||
| - "@lwc/engine-dom" | ||
| - "@lwc/errors" | ||
| - "@lwc/features" | ||
| - "@lwc/module-resolver" | ||
| - "@lwc/rollup-plugin" | ||
| - "@lwc/shared" | ||
| - "@lwc/signals" | ||
| - "@lwc/ssr-client-utils" | ||
| - "@lwc/ssr-compiler" | ||
| - "@lwc/ssr-runtime" | ||
| - "@lwc/style-compiler" | ||
| - "@lwc/synthetic-shadow" | ||
| - "@lwc/template-compiler" | ||
| - "@lwc/types" | ||
| - "@lwc/wire-service" | ||
|
|
||
| build: | ||
| - npm-setup: | ||
| yarn-modern: true | ||
| - step: | ||
| name: yarn-build | ||
| image: docker.repo.local.sfdc.net/sfci/docker-images/sfdc_rhel9_nodejs20/sfdc_rhel9_nodejs20_build:latest | ||
| commands: | ||
| - yarn install | ||
| - yarn build | ||
| - yarn test | ||
| integration-test: | ||
| - downstream-dependency: | ||
| downstream-repos: | ||
| - repo-url: https://github.com/salesforce-experience-platform-emu/lwc-platform | ||
| branches: | ||
| - master | ||
| packages-to-test: | ||
| npm: | ||
| - '@lwc/aria-reflection' | ||
| - '@lwc/babel-plugin-component' | ||
| - '@lwc/compiler' | ||
| - '@lwc/engine-core' | ||
| - '@lwc/engine-dom' | ||
| - '@lwc/errors' | ||
| - '@lwc/features' | ||
| - '@lwc/module-resolver' | ||
| - '@lwc/rollup-plugin' | ||
| - '@lwc/shared' | ||
| - '@lwc/signals' | ||
| - '@lwc/ssr-client-utils' | ||
| - '@lwc/ssr-compiler' | ||
| - '@lwc/ssr-runtime' | ||
| - '@lwc/style-compiler' | ||
| - '@lwc/synthetic-shadow' | ||
| - '@lwc/template-compiler' | ||
| - '@lwc/types' | ||
| - '@lwc/wire-service' |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,9 +7,14 @@ | |
| import path from 'node:path'; | ||
| import { describe } from 'vitest'; | ||
| import { transformSync } from '@babel/core'; | ||
| import babelClassPropertiesPlugin from '@babel/plugin-transform-class-properties'; | ||
| import { LWC_VERSION, HIGHEST_API_VERSION } from '@lwc/shared'; | ||
| import { testFixtureDir } from '@lwc/test-utils-lwc-internals'; | ||
| import plugin, { type LwcBabelPluginOptions } from '../index'; | ||
| import plugin, { | ||
| LwcPrivateMethodTransform, | ||
| LwcReversePrivateMethodTransform, | ||
| type LwcBabelPluginOptions, | ||
| } from '../index'; | ||
|
|
||
| interface TestConfig extends LwcBabelPluginOptions { | ||
| experimentalErrorRecoveryMode?: boolean; | ||
|
|
@@ -82,7 +87,7 @@ | |
| testFixtureDir<TestConfig>( | ||
| { | ||
| root: path.resolve(import.meta.dirname, 'fixtures'), | ||
| pattern: '**/actual.js', | ||
| pattern: '!(private-methods)/**/actual.js', | ||
| ssrVersion: 2, | ||
| }, | ||
| ({ src, config }) => { | ||
|
|
@@ -110,3 +115,55 @@ | |
| } | ||
| ); | ||
| }); | ||
|
|
||
| function transformWithPrivateMethodPipeline(source: string, opts = {}) { | ||
| const testConfig = { | ||
| ...BASE_CONFIG, | ||
| parserOpts: (opts as any).parserOpts ?? {}, | ||
| plugins: [ | ||
| LwcPrivateMethodTransform, | ||
| [plugin, { ...BASE_OPTS, ...opts }], | ||
| [babelClassPropertiesPlugin, { loose: true }], | ||
| LwcReversePrivateMethodTransform, | ||
| ], | ||
| }; | ||
|
|
||
| const result = transformSync(source, testConfig)!; | ||
|
|
||
| let { code } = result; | ||
|
|
||
| code = code!.replace(new RegExp(LWC_VERSION.replace(/\./g, '\\.'), 'g'), 'X.X.X'); | ||
|
|
||
| code = code.replace( | ||
| new RegExp(`apiVersion: ${HIGHEST_API_VERSION}`, 'g'), | ||
| `apiVersion: 9999999` | ||
| ); | ||
|
|
||
| return { code }; | ||
| } | ||
|
|
||
| describe.skip('private-methods fixtures', () => { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Skipped for now because the fixtures folder is empty but once a-chabot#2 gets merged in, this will get re-enabled |
||
| testFixtureDir( | ||
| { | ||
| root: path.resolve(import.meta.dirname, 'fixtures', 'private-methods'), | ||
| pattern: '**/actual.js', | ||
| ssrVersion: 2, | ||
| }, | ||
| ({ src, config }) => { | ||
| let code; | ||
| let error; | ||
|
|
||
| try { | ||
| const result = transformWithPrivateMethodPipeline(src, config); | ||
| code = result.code; | ||
| } catch (err) { | ||
| error = JSON.stringify(normalizeError(err), null, 4); | ||
| } | ||
|
|
||
| return { | ||
| 'expected.js': code, | ||
| 'error.json': error, | ||
| }; | ||
| } | ||
| ); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will get replaced with the tests that are in this PR: a-chabot#2