@jsenv/ast 3.0.1 → 3.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/ast",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "Parse and transform HTML,CSS and JS",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -33,7 +33,7 @@
33
33
  "test": "node --conditions=development ./scripts/test.mjs"
34
34
  },
35
35
  "dependencies": {
36
- "@babel/parser": "7.20.13",
36
+ "@babel/parser": "7.21.3",
37
37
  "acorn": "8.8.2",
38
38
  "acorn-import-assertions": "1.8.0",
39
39
  "acorn-walk": "8.2.0",
@@ -1,5 +1,7 @@
1
1
  import { fileURLToPath } from "node:url"
2
2
 
3
+ import { createCssParseError } from "./css_parse_error.js"
4
+
3
5
  export const applyPostCss = async ({
4
6
  sourcemaps = "comment",
5
7
  plugins,
@@ -32,8 +34,13 @@ export const applyPostCss = async ({
32
34
  }
33
35
  } catch (error) {
34
36
  if (error.name === "CssSyntaxError") {
35
- console.error(String(error))
36
- throw error
37
+ throw createCssParseError({
38
+ message: error.message,
39
+ reasonCode: error.reason,
40
+ url,
41
+ line: error.line,
42
+ column: error.column,
43
+ })
37
44
  }
38
45
  throw error
39
46
  }
@@ -0,0 +1,15 @@
1
+ export const createCssParseError = ({
2
+ message,
3
+ reasonCode,
4
+ url,
5
+ line,
6
+ column,
7
+ }) => {
8
+ const parseError = new Error(message)
9
+ parseError.reasonCode = reasonCode
10
+ parseError.code = "PARSE_ERROR"
11
+ parseError.url = url
12
+ parseError.line = line
13
+ parseError.column = column
14
+ return parseError
15
+ }
@@ -19,6 +19,7 @@ export const parseJsWithAcorn = async ({ js, url, isJsModule }) => {
19
19
  const { line, column } = _getLineInfo(js, e.raisedAt)
20
20
  throw createJsParseError({
21
21
  message: e.message,
22
+ reasonCode: e.message,
22
23
  url,
23
24
  line,
24
25
  column,