browserslist-generator icon indicating copy to clipboard operation
browserslist-generator copied to clipboard

'javascript.builtins.Array.at' is unknown

Open jaswrks opened this issue 9 months ago • 4 comments

Occurs on Node 20.5.1 running 2.1.0.

TypeError: The given feature: 'javascript.builtins.Array.at' is unknown. It must be a valid Caniuse or MDN feature!

I noticed the MDN import changed to a glob * import in the latest release. Not sure if that has something to do with it, but I was getting some warnings about experimental use of JSON import assertions also. If I revert back to previous version of browserslist-generator, all is fine. Still get the warning about experimental import assertions, though.

jaswrks avatar Sep 17 '23 09:09 jaswrks

(node:47818) ExperimentalWarning: Import assertions are not a stable feature of the JavaScript language. Avoid relying on their current behavior and syntax as those might change in a future version of Node.js.
(Use `node --trace-warnings ...` to show where the warning was created)
TypeError: The given feature: 'javascript.builtins.Array.at' is unknown. It must be a valid Caniuse or MDN feature!
    at assertKnownFeature (.../node_modules/browserslist-generator/dist/esm/index.js:1175:15)
    at getFeatureSupport (.../node_modules/browserslist-generator/dist/esm/index.js:1194:5)
    at browserSupportForFeaturesCommon (.../node_modules/browserslist-generator/dist/esm/index.js:1317:25)
    at browsersWithSupportForFeatures (.../node_modules/browserslist-generator/dist/esm/index.js:974:33)
    at browsersWithSupportForEcmaVersion (.../node_modules/browserslist-generator/dist/esm/index.js:1058:20)
    at Module.default (.../dev/.files/bin/browserslist/index.mjs:62:46)
    at BrowsersList.update (.../dev/.files/bin/update.mjs:227:98)
    at async BrowsersList.run (.../dev/.files/bin/update.mjs:210:3)
    at async Object.handler (.../dev/.files/bin/update.mjs:859:5)

jaswrks avatar Sep 17 '23 09:09 jaswrks

I've got the same issue and I thing it's related to this line: https://github.com/wessberg/browserslist-generator/blob/80d81a43462da37426ac08b4fff72f468ef4f495/src/browserslist-generator/browserslist-generator.ts#L3

When executed in Node 19.2 imported from an ES module, because of the namespace import (* as), compatData is equal to Module {default: Accessor, Symbol(Symbol.toStringTag): "Module"} That means if you want to read javascript.builtins.Array.at, you need to access it as compatData.default.javascript.builtins.Array.at.

mems avatar Sep 21 '23 12:09 mems

Thanks @mems, I patched this locally and it works:

diff --git a/dist/esm/index.js b/dist/esm/index.js
index 5f01ddfca542c54ffedced4d4489aff4843d6067..2180bc326bd27c4c0d088aa06af185aadbd0b22b 100644
--- a/dist/esm/index.js
+++ b/dist/esm/index.js
@@ -1,6 +1,6 @@
 import Browserslist from 'browserslist';
 import { feature, features } from 'caniuse-lite';
-import * as compatData from '@mdn/browser-compat-data' assert { type: 'json' };
+import compatData from '@mdn/browser-compat-data' assert { type: 'json' };
 import objectPath from 'object-path';
 import { coerce, lt, gt, gte, lte } from 'semver';
 import { UAParser } from 'ua-parser-js';

laverdet avatar Sep 29 '23 02:09 laverdet

Thanks so much. Is there an ETA on when there will be a release available that patches this?

jaswrks avatar Nov 26 '23 06:11 jaswrks