An ES6 module is a JavaScript file that explicitly exports variables
or functions that other modules can use. Modules make it easier to
structure your code without polluting the global scope.
Everything in LWC which is imported and Exported is a ES6 module.
JavaScript files in Lightning web components are ES6 modules. By
default, everything declared in a module is local—it’s scoped to the
module.
As this is basically es6 and not just LWC, I tried searching import all from es6
.
Surprisingly, there are many results, I tried a solution from most accepted and most voted answer that suggested exporting * first and then importing it in new component.
My code which exports all lables in AllLables
module
import { LightningElement } from 'lwc';
export * from '@salesforce/label';
export default class AllLables extends LightningElement {
}
when I try saving it, I get this error:
LWC1507: Exporting * from @salesforce/label is not allowed.
Apparently, even if there is the way in ES6, SF is intentionally blocking it, probably for the same reason it does not allow SELECT * in SOQL
You have to use Apex :(
UPDATE 9/2019
As of Summer '19 v46.0, force:source:deploy
now works when deploying to production, and you'll no longer get that testLevel error message.
You can set the test level using the -l
flag and use -u
to point to your connected Production org:
sfdx force:source:deploy -m ApexClass:MyClass -l RunLocalTests -u MyProductionOrg
OLD ANSWER
If you're using force:source:deploy
, it doesn't work when deploying to production, which is why those testLevel
errors are showing up. As of Spring 19, you can't adjust those parameters (and this is by design as far as I can tell). This limitation can be found on the force:source:deploy
documentation:
The force:source:deploy, force:source:retrieve, and force:source:delete commands work on sandboxes, Developer Edition orgs, and trial orgs, but not production orgs. For production orgs, continue to use force:mdapi:deploy and force:mdapi:retrieve.
For a nice trick to deploy from Sandbox to Production, see my answer to this post - I use this on a daily basis now
Best Answer
I chose an unrelated apex test class and it deployed successfully to production.