Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn lors de l'import d'un JSON dans des projets JS #10

Open
hrenaud opened this issue Apr 11, 2024 · 1 comment
Open

Warn lors de l'import d'un JSON dans des projets JS #10

hrenaud opened this issue Apr 11, 2024 · 1 comment

Comments

@hrenaud
Copy link

hrenaud commented Apr 11, 2024

Je l'avais remonté à @tsecher sur son ancien repo, mais la méthode proposée sur le readme génère des warns car assert {type: 'json'} pourrait être abandonné par Node à tout moment.

(node:1884) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time

Il faudrait proposer, en plus de ce JSON un JS qui ferait exactement la même chose et l'ajouter dans les files du package.json.

// ecoindex_reference.js
module.exports = {
  "quantiles": {
    "dom_size": [
      0,
      47,
      75,
      159,
      233,
      298,
      358,
      417,
      476,
      537,
      603,
      674,
      753,
      843,
      949,
      1076,
      1237,
      1459,
      1801,
      2479,
      594601
    ],
    "nb_request": [
      0,
      2,
      15,
      25,
      34,
      42,
      49,
      56,
      63,
      70,
      78,
      86,
      95,
      105,
      117,
      130,
      147,
      170,
      205,
      281,
      3920
    ],
    "response_size": [
      0,
      1.37,
      144.7,
      319.53,
      479.46,
      631.97,
      783.38,
      937.91,
      1098.62,
      1265.47,
      1448.32,
      1648.27,
      1876.08,
      2142.06,
      2465.37,
      2866.31,
      3401.59,
      4155.73,
      5400.08,
      8037.54,
      223212.26
    ]
  },
  "targets": {
    "dom_size": 600,
    "nb_request": 40,
    "response_size": 1024
  },
  "medians": {
    "dom_size": 693,
    "nb_request": 78,
    "response_size": 2420
  },
  "grades": [
    {
      "value": 80,
      "grade": "A",
      "color": "#349A47"
    },
    {
      "value": 70,
      "grade": "B",
      "color": "#51B84B"
    },
    {
      "value": 55,
      "grade": "C",
      "color": "#CADB2A"
    },
    {
      "value": 40,
      "grade": "D",
      "color": "#F6EB15"
    },
    {
      "value": 25,
      "grade": "E",
      "color": "#FECD06"
    },
    {
      "value": 10,
      "grade": "F",
      "color": "#F99839"
    },
    {
      "value": 0,
      "grade": "G",
      "color": "#ED2124"
    }
  ]
}
@hrenaud
Copy link
Author

hrenaud commented Jun 4, 2024

Je reviens à la charge sur ce point. Cela générait des warns en node 18, en node 20 ça génère des erreurs.

import reference from 'ecoindex_reference' assert {type: 'json'};
                                           ^^^^^^

SyntaxError: Unexpected identifier 'assert'
    at compileSourceTextModule (node:internal/modules/esm/utils:337:16)
    at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:163:18)
    at callTranslator (node:internal/modules/esm/loader:430:14)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:436:30)

Node.js v22.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant