Closed apapko closed 5 years ago
Yes, we already have a doc and a plan. Wil lbe adding it to RFC shortly
this goes beyond that... we should also prevent people from doing this:
import * as foo from "lwc";
We already do that :)
@pmdartus as part of this change, I will like to see lwc/template
to export two things: api
and template
function, so, template sign the function, and api
is just a direct way to access $api
instead of using the argument, which I think is the right approach.
@diervo Where do we prevent this pattern? I am not aware at least of any linting rule checking against this.
import * as foo from "lwc";
@apapko @pmdartus @diervo can we close this now? I think the restriction is in place now.
This is half done, the restriction are in place: https://github.com/salesforce/lwc/blob/master/packages/babel-plugin-transform-lwc-class/src/__tests__/component.spec.js#L7-L87
However, you can still import some internal APIs we don't want to expose:
dangerousObjectMutation
createElement
getComponentDef
We discussed with this @apapko and @diervo last week. We need before GA to move those restrictions from the OSS javascript transformer to the platform compiler. While consumer can still import those APIs in locally for testing purpose we would block the push on the platform.
Let's close this issue for now since we are tracking it elsewhere.
Is your feature request related to a problem? Please describe. Today LWC consumers are able to import createElement and dynamically create LWC components
Describe the solution you'd like Prevent users from using internal engine api for dynamic component creation
Describe alternatives you've considered We can add a linting rule or detect the usage during compilation
@diervo did you have a specific approach in mind?