Skip to content

Commit c0f1b07

Browse files
fcortesFelipe CortésdimaMachina
authored
Stop using experimental syntax to load package version (#2616)
* chore: stop using experimental syntax to load package version The import attribute syntax (`with { type: "json" }`) is still experimental so warnings showed up when using the library as it was being used to import the package.json file to extract the package version As an alternative, the current version will be injected on build time through tsup configuration. * Create healthy-moose-kneel.md * fix: failing test on node v22 after warning format change The test was failing because the line number in one of the warnings being suppressed changed from 5 characters to 7 on node v22. The other rule suppression was removed as a previous commit fixed the undelying issue. --------- Co-authored-by: Felipe Cortés <[email protected]> Co-authored-by: Dimitri POSTOLOV <[email protected]>
1 parent b916bc9 commit c0f1b07

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

.changeset/healthy-moose-kneel.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@graphql-eslint/eslint-plugin": patch
3+
---
4+
5+
The import attribute syntax (with { type: "json" }) is still experimental so warnings showed up when using the library as it was being used to import the package.json file to extract the package version
6+
7+
As an alternative, the current version will be injected on build time through tsup configuration.

packages/plugin/__tests__/examples.spec.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,10 @@ function getESLintOutput(cwd: string): ESLint.LintResult[] {
2222
const errorOutput = stderr
2323
.toString()
2424
.replace(
25-
/\(node:\d{4,5}\) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time/,
25+
/\(node:\d{4,7}\) \[DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead./,
2626
'',
2727
)
28-
.replace(
29-
/\(node:\d{4,5}\) \[DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead./,
30-
'',
31-
)
32-
.replace('(Use `node --trace-warnings ...` to show where the warning was created)', '')
28+
.replace('(Use `node --trace-deprecation ...` to show where the warning was created)', '')
3329
.trimEnd();
3430
if (errorOutput) {
3531
throw new Error(errorOutput);

packages/plugin/src/meta.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
import packageJson from '../package.json' with { type: 'json' };
2-
3-
export const { version } = packageJson;
1+
export const version = process.env.VERSION

packages/plugin/tsup.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const opts: Options = {
1010
dts: true,
1111
env: {
1212
...(process.env.NODE_ENV && { NODE_ENV: process.env.NODE_ENV }),
13+
VERSION: packageJson.version,
1314
},
1415
format: 'esm',
1516
minifySyntax: true,

0 commit comments

Comments
 (0)