Move JS Modules to the "allowed features" of the WebUI ES styleguide.
Also add a new "Dynamic import" entry, in the "To Be Discussed" section, to ensure that we don't accidentally allow dynamic imports before examining any complications (for example ESLint breakage) further. Bug: 915053 Change-Id: I0f166cabcedfd4cc8cc445ad177e5344d7ac8b71 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1733576 Reviewed-by: Dan Beam <dbeam@chromium.org> Commit-Queue: Rebekah Potter <rbpotter@chromium.org> Cr-Commit-Position: refs/heads/master@{#691394}
This commit is contained in:
@ -563,6 +563,31 @@ const [one, ...rest] = [1, 2, 3];
|
||||
|
||||
---
|
||||
|
||||
### Modules
|
||||
|
||||
Support for exporting/importing values from/to modules without global
|
||||
namespace pollution.
|
||||
|
||||
**Usage Example:**
|
||||
|
||||
```js
|
||||
// lib/rect.js
|
||||
export function getArea() {...};
|
||||
export {width, height, unimportant};
|
||||
|
||||
// app.js
|
||||
import {getArea, width, height} from './lib/rect.js';
|
||||
```
|
||||
|
||||
**Documentation:** [link](https://developers.google.com/web/fundamentals/primers/modules)
|
||||
|
||||
**Discussion Notes / Link to Thread:**
|
||||
Dynamic Import [link](https://v8.dev/features/dynamic-import) are not allowed
|
||||
yet, see separate entry in the [Features To Be Discussed](##es2015-support-in-chromium-features-to-be-discussed)
|
||||
section.
|
||||
|
||||
---
|
||||
|
||||
## Banned Features
|
||||
|
||||
The following features are banned for Chromium development.
|
||||
@ -730,12 +755,10 @@ result === 'yy' && re.lastIndex === 5; // true
|
||||
|
||||
**Discussion Notes / Link to Thread:**
|
||||
|
||||
---
|
||||
### Dynamic Import
|
||||
|
||||
### Modules
|
||||
|
||||
Support for exporting/importing values from/to modules without global
|
||||
namespace pollution.
|
||||
Dynamic import() introduces a new function-like form of import that returns a
|
||||
promise for the module namespace object of the requested module.
|
||||
|
||||
**Usage Example:**
|
||||
|
||||
@ -745,10 +768,14 @@ export function getArea() {...};
|
||||
export {width, height, unimportant};
|
||||
|
||||
// app.js
|
||||
import {getArea, width, height} from './lib/rect.js';
|
||||
if (calculateArea) {
|
||||
import('./lib/rect.js').then(rect => {
|
||||
rect.getArea(...);
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
**Documentation:** [link](https://developers.google.com/web/fundamentals/primers/modules)
|
||||
**Documentation:** [link](https://v8.dev/features/dynamic-import)
|
||||
|
||||
**Discussion Notes / Link to Thread:**
|
||||
|
||||
|
Reference in New Issue
Block a user