detective-vue2 2.0.1 → 2.0.3

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.
Files changed (3) hide show
  1. package/README.md +1 -0
  2. package/index.js +12 -10
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -9,6 +9,7 @@
9
9
  ```sh
10
10
  npm install detective-vue2 typescript
11
11
  ```
12
+
12
13
  ## Usage
13
14
 
14
15
  ```js
package/index.js CHANGED
@@ -10,20 +10,22 @@ const detectiveSass = require('detective-sass');
10
10
  /**
11
11
  * Extracts the dependencies of the supplied Vue module
12
12
  */
13
- module.exports = function(fileContent, opts) {
14
- if (fileContent === undefined) throw new Error('content not given');
15
- if (typeof fileContent !== 'string') throw new Error('content is not a string');
13
+ module.exports = function(content, options) {
14
+ if (content === undefined) throw new Error('content not given');
15
+ if (typeof content !== 'string') throw new Error('content is not a string');
16
16
 
17
- const result = compiler.parse(fileContent, { sourceMap: false });
18
- const { styles, script } = result.descriptor;
17
+ const result = compiler.parse(content, { sourceMap: false });
18
+ const { styles, script, scriptSetup } = result.descriptor;
19
19
 
20
20
  const dependencies = [];
21
21
 
22
- if (script?.content) {
23
- if (script.attrs?.lang === 'ts') {
24
- dependencies.push(...detectiveTypeScript(script.content, opts));
25
- } else {
26
- dependencies.push(...detectiveEs6(script.content, opts));
22
+ for (const usedScript of [script, scriptSetup]) {
23
+ if (usedScript?.content) {
24
+ if (usedScript.attrs?.lang === 'ts') {
25
+ dependencies.push(...detectiveTypeScript(usedScript.content, options));
26
+ } else {
27
+ dependencies.push(...detectiveEs6(usedScript.content, options));
28
+ }
27
29
  }
28
30
  }
29
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "detective-vue2",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "author": "Havunen <sampo.kivisto@live.fi>",
5
5
  "description": "Get the dependencies of a Vue module",
6
6
  "main": "index.js",
@@ -39,7 +39,7 @@
39
39
  "typescript": "^5.4.4"
40
40
  },
41
41
  "dependencies": {
42
- "@vue/compiler-sfc": "^3.4.21",
42
+ "@vue/compiler-sfc": "^3.4.27",
43
43
  "detective-es6": "^5.0.0",
44
44
  "detective-sass": "^6.0.0",
45
45
  "detective-scss": "^5.0.0",