| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent fce3ab6 commit ac37e55
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -251,14 +251,10 @@ changes: | |||
| 251 | 251 | description: Switch from Import Assertions to Import Attributes. | |
| 252 | 252 | --> | |
| 253 | 253 | ||
| 254 | - > Stability: 1.1 - Active development | ||
| 255 | - | ||
| 256 | - > This feature was previously named "Import assertions", and using the `assert` | ||
| 257 | - > keyword instead of `with`. Any uses in code of the prior `assert` keyword | ||
| 258 | - > should be updated to use `with` instead. | ||
| 254 | + > Stability: 2 - Stable | ||
| 259 | 255 | ||
| 260 | - The [Import Attributes proposal][] adds an inline syntax for module import | ||
| 261 | - statements to pass on more information alongside the module specifier. | ||
| 256 | + [Import attributes][Import Attributes MDN] are an inline syntax for module | ||
| 257 | + import statements to pass on more information alongside the module specifier. | ||
| 262 | 258 | ||
| 263 | 259 | ```js | |
| 264 | 260 | import fooData from './foo.json' with { type: 'json' }; | |
@@ -267,13 +263,15 @@ const { default: barData } = | |||
| 267 | 263 | await import('./bar.json', { with: { type: 'json' } }); | |
| 268 | 264 | ``` | |
| 269 | 265 | ||
| 270 | - Node.js supports the following `type` values, for which the attribute is | ||
| 271 | - mandatory: | ||
| 266 | + Node.js only supports the `type` attribute, for which it supports the following | ||
| 267 | + values: | ||
| 272 | 268 | ||
| 273 | 269 | | Attribute `type` | Needed for | | |
| 274 | 270 | | ---------------- | ---------------- | | |
| 275 | 271 | | `'json'` | [JSON modules][] | | |
| 276 | 272 | ||
| 273 | + The `type: 'json'` attribute is mandatory when importing JSON modules. | ||
| 274 | + | ||
| 277 | 275 | ## Builtin modules | |
| 278 | 276 | ||
| 279 | 277 | [Core modules][] provide named exports of their public API. A | |
@@ -552,7 +550,7 @@ separate cache. | |||
| 552 | 550 | ||
| 553 | 551 | ## JSON modules | |
| 554 | 552 | ||
| 555 | - > Stability: 1 - Experimental | ||
| 553 | + > Stability: 2 - Stable | ||
| 556 | 554 | ||
| 557 | 555 | JSON files can be referenced by `import`: | |
| 558 | 556 | ||
@@ -1090,7 +1088,7 @@ success! | |||
| 1090 | 1088 | [Dynamic `import()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import | |
| 1091 | 1089 | [ES Module Integration Proposal for WebAssembly]: https://github.com/webassembly/esm-integration | |
| 1092 | 1090 | [Import Attributes]: #import-attributes | |
| 1093 | - [Import Attributes proposal]: https://github.com/tc39/proposal-import-attributes | ||
| 1091 | + [Import Attributes MDN]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import/with | ||
| 1094 | 1092 | [JSON modules]: #json-modules | |
| 1095 | 1093 | [Module customization hooks]: module.md#customization-hooks | |
| 1096 | 1094 | [Node.js Module Resolution And Loading Algorithm]: #resolution-algorithm-specification | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -304,8 +304,7 @@ translators.set('builtin', async function builtinStrategy(url) { | |||
| 304 | 304 | }); | |
| 305 | 305 | ||
| 306 | 306 | // Strategy for loading a JSON file | |
| 307 | - translators.set('json', async function jsonStrategy(url, source) { | ||
| 308 | - emitExperimentalWarning('Importing JSON modules'); | ||
| 307 | + translators.set('json', function jsonStrategy(url, source) { | ||
| 309 | 308 | assertBufferSource(source, true, 'load'); | |
| 310 | 309 | debug(`Loading JSONModule ${url}`); | |
| 311 | 310 | const pathname = StringPrototypeStartsWith(url, 'file:') ? | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,12 +14,12 @@ describe('ESM: importing JSON', () => { | |||
| 14 | 14 | assert.strictEqual(secret.ofLife, 42); | |
| 15 | 15 | }); | |
| 16 | 16 | ||
| 17 | - it('should print an experimental warning', async () => { | ||
| 17 | + it('should not print an experimental warning', async () => { | ||
| 18 | 18 | const { code, signal, stderr } = await spawnPromisified(execPath, [ | |
| 19 | 19 | fixtures.path('/es-modules/json-modules.mjs'), | |
| 20 | 20 | ]); | |
| 21 | 21 | ||
| 22 | - assert.match(stderr, /ExperimentalWarning: Importing JSON modules/); | ||
| 22 | + assert.strictEqual(stderr, ''); | ||
| 23 | 23 | assert.strictEqual(code, 0); | |
| 24 | 24 | assert.strictEqual(signal, null); | |
| 25 | 25 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments