File tree Expand file tree Collapse file tree 3 files changed +22
-4
lines changed
test/fixtures/fake-test262/test/language/module-code Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Original file line number Diff line number Diff line change 33const fs = require ( 'fs' ) ;
44const path = require ( 'path' ) ;
55const rawSourceCache = new Map ( ) ;
6+ const dependencySuffixes = / \. j s | \. m j s | \. j s o n / ;
7+ const dependencySuffixesRight = new RegExp ( `(${ dependencySuffixes . source } )$` ) ;
68
79function escapeModuleSpecifier ( string ) {
810 return string . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, '\\$&' ) ;
@@ -25,13 +27,11 @@ function findModuleSpecifiers(source) {
2527 // be parseable.
2628 let lines = source . split ( / \r ? \n / g) ;
2729 return lines . reduce ( ( accum , line ) => {
28- if ( line . includes ( '.js' ) || line . includes ( '.mjs' ) ) {
30+ if ( dependencySuffixes . test ( line ) ) {
2931 let parsed = / ( i m p o r t | i m p o r t \( | f r o m ) ( \s * ) ( ' ( .* ?) ' | " ( .* ?) " ) / g. exec ( line ) ;
3032 if ( parsed && parsed . length ) {
3133 for ( let entry of parsed ) {
32- if ( entry &&
33- ( entry . endsWith ( '.js' ) || entry . endsWith ( '.mjs' ) ) &&
34- ! accum . includes ( entry ) ) {
34+ if ( entry && dependencySuffixesRight . test ( entry ) && ! accum . includes ( entry ) ) {
3535 accum . push ( entry . replace ( './' , '' ) ) ;
3636 }
3737 }
Original file line number Diff line number Diff line change 1+ // Copyright (C) 2021 the V8 project authors. All rights reserved.
2+ // This code is governed by the BSD license found in the LICENSE file.
3+ /*---
4+ description: This is a test for loading files with a `.json` extension.
5+ esid: sec-parsemodule
6+ flags: [module]
7+ ---*/
8+
9+ import './json-module_FIXTURE.json' ;
10+
11+ /**
12+ * At the time of this writing, neither the "import assertions" proposal [1]
13+ * nor the "JSON modules" proposal [2] are widely implemented. In order to
14+ * verify that the harness correctly identifies JSON dependencies without
15+ * requiring the new semantics, this test simply loads a JSON file which
16+ * happens to parse as JavaScript, and it does not validate the exported value.
17+ */
Original file line number Diff line number Diff line change 1+ " This file is valid JSON and valid JavaScript."
You can’t perform that action at this time.
0 commit comments