Compare commits

...

1 Commits

Author SHA1 Message Date
Faisal Salman
41dd83f27a Fix #814 - Resolve syntax error related to import renaming in ESM version build 2025-12-10 11:27:02 +07:00
3 changed files with 6 additions and 3 deletions

View File

@@ -232,9 +232,9 @@
"fuzz": "jazzer ./test/fuzz/redos.js --sync", "fuzz": "jazzer ./test/fuzz/redos.js --sync",
"test": "./script/test-all.sh", "test": "./script/test-all.sh",
"test:dts-lint": "tsd --typings src/main/ua-parser.d.ts --files test/static/dts-lint.ts", "test:dts-lint": "tsd --typings src/main/ua-parser.d.ts --files test/static/dts-lint.ts",
"test:eslint": "eslint src && eslint script", "test:eslint": "eslint --no-config-lookup src",
"test:jshint": "jshint src/main", "test:jshint": "jshint src/main",
"test:lockfile-lint": "npx lockfile-lint -p package-lock.json", "test:lockfile-lint": "lockfile-lint -p package-lock.json",
"test:mocha": "mocha --recursive test/unit", "test:mocha": "mocha --recursive test/unit",
"test:playwright": "npx playwright install && playwright test test/e2e --browser all" "test:playwright": "npx playwright install && playwright test test/e2e --browser all"
}, },
@@ -247,7 +247,9 @@
"@babel/parser": "7.15.8", "@babel/parser": "7.15.8",
"@babel/traverse": "7.23.2", "@babel/traverse": "7.23.2",
"@playwright/test": "^1.57.0", "@playwright/test": "^1.57.0",
"eslint": "^9.39.1",
"jshint": "~2.13.6", "jshint": "~2.13.6",
"lockfile-lint": "^4.14.1",
"mocha": "~8.2.0", "mocha": "~8.2.0",
"requirejs": "2.3.2", "requirejs": "2.3.2",
"safe-regex": "^2.1.1", "safe-regex": "^2.1.1",

View File

@@ -4,6 +4,7 @@ const fs = require('fs');
const defaultReplacements = { const defaultReplacements = {
mjs: [ mjs: [
[/(?<=const.+)(:)(?=.+require)/ig, ' as'],
[/const (.+?)\s*=\s*require\(\'\.(.+)\'\)/ig, 'import $1 from \'\.$2.mjs\''], [/const (.+?)\s*=\s*require\(\'\.(.+)\'\)/ig, 'import $1 from \'\.$2.mjs\''],
[/const (.+?)\s*=\s*require\(\'(.+)\'\)/ig, 'import $1 from \'$2\''], [/const (.+?)\s*=\s*require\(\'(.+)\'\)/ig, 'import $1 from \'$2\''],
[/module\.exports =/ig, 'export'] [/module\.exports =/ig, 'export']

View File

@@ -9,7 +9,7 @@ echo '
- lint js code - lint js code
' '
npm run test:jshint || exit 1 npm run test:jshint || exit 1
#npm run test:eslint || exit 1 npm run test:eslint || exit 1
echo ' echo '
- test using mocha - test using mocha