@yozora/tokenizer-ecma-import 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -8,11 +8,13 @@ var coreTokenizer = require('@yozora/core-tokenizer');
8
8
 
9
9
  const namedImportItemRegex = /^(\w+)(?:\s+as\s+(\w+))?$/;
10
10
  const namedImportRegex = /\{\s*((?:[\w]+(?:\s+as\s+[\w]+)?\s*,\s*)*[\w]+(?:\s+as\s+[\w]+)?)\s*\}\s*/;
11
- const regex1 = /^import\s+(['"])([^'"]+)\1$/;
12
- const regex2 = /^import\s+([\w]+)\s+from\s+(['"])([^'"]+)\2$/;
11
+ const endRegex = /\s*;*\s*$/;
12
+ const regex1 = new RegExp(/^import\s+(['"])([^'"]+)\1/.source + endRegex.source);
13
+ const regex2 = new RegExp(/^import\s+([\w]+)\s+from\s+(['"])([^'"]+)\2/.source + endRegex.source);
13
14
  const regex3 = new RegExp(/^import\s+(?:([\w]+)\s*,\s*)?/.source +
14
15
  namedImportRegex.source +
15
- /from\s+(['"])([^'"]+)\3$/.source);
16
+ /from\s+(['"])([^'"]+)\3/.source +
17
+ endRegex.source);
16
18
  function resolveNameImports(text) {
17
19
  const items = text.split(/\s*,\s*/g).filter(item => item.length > 0);
18
20
  const result = [];
package/lib/esm/index.js CHANGED
@@ -4,11 +4,13 @@ import { calcStartPoint, calcEndPoint, BaseBlockTokenizer, TokenizerPriority } f
4
4
 
5
5
  const namedImportItemRegex = /^(\w+)(?:\s+as\s+(\w+))?$/;
6
6
  const namedImportRegex = /\{\s*((?:[\w]+(?:\s+as\s+[\w]+)?\s*,\s*)*[\w]+(?:\s+as\s+[\w]+)?)\s*\}\s*/;
7
- const regex1 = /^import\s+(['"])([^'"]+)\1$/;
8
- const regex2 = /^import\s+([\w]+)\s+from\s+(['"])([^'"]+)\2$/;
7
+ const endRegex = /\s*;*\s*$/;
8
+ const regex1 = new RegExp(/^import\s+(['"])([^'"]+)\1/.source + endRegex.source);
9
+ const regex2 = new RegExp(/^import\s+([\w]+)\s+from\s+(['"])([^'"]+)\2/.source + endRegex.source);
9
10
  const regex3 = new RegExp(/^import\s+(?:([\w]+)\s*,\s*)?/.source +
10
11
  namedImportRegex.source +
11
- /from\s+(['"])([^'"]+)\3$/.source);
12
+ /from\s+(['"])([^'"]+)\3/.source +
13
+ endRegex.source);
12
14
  function resolveNameImports(text) {
13
15
  const items = text.split(/\s*,\s*/g).filter(item => item.length > 0);
14
16
  const result = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yozora/tokenizer-ecma-import",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "author": {
5
5
  "name": "guanghechen",
6
6
  "url": "https://github.com/guanghechen/"
@@ -35,9 +35,9 @@
35
35
  "test": "cross-env TS_NODE_FILES=true jest --config ../../jest.config.js --rootDir ."
36
36
  },
37
37
  "dependencies": {
38
- "@yozora/ast": "^2.0.0",
39
- "@yozora/character": "^2.0.0",
40
- "@yozora/core-tokenizer": "^2.0.0"
38
+ "@yozora/ast": "^2.0.1",
39
+ "@yozora/character": "^2.0.1",
40
+ "@yozora/core-tokenizer": "^2.0.1"
41
41
  },
42
- "gitHead": "65e99d1709fdd1c918465dce6b1e91de96bdab5e"
42
+ "gitHead": "3aea33091e402bd6c7754d91d549e8d648475073"
43
43
  }