salesforce / lwc

⚡️ LWC - A Blazing Fast, Enterprise-Grade Web Components Foundation
https://lwc.dev
Other
1.63k stars 394 forks source link

prevent engine internal api usage in user land code #622

Closed apapko closed 5 years ago

apapko commented 6 years ago

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?

diervo commented 6 years ago

Yes, we already have a doc and a plan. Wil lbe adding it to RFC shortly

caridy commented 6 years ago

this goes beyond that... we should also prevent people from doing this:

import * as foo from "lwc";
diervo commented 6 years ago

We already do that :)

caridy commented 6 years ago

@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.

pmdartus commented 6 years ago

@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";
caridy commented 5 years ago

@apapko @pmdartus @diervo can we close this now? I think the restriction is in place now.

pmdartus commented 5 years ago

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:

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.