Skip to content

Commit

Permalink
Stop using experimental syntax to load package version (#2616)
Browse files Browse the repository at this point in the history
* 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 <felipe@cortes.cl>
Co-authored-by: Dimitri POSTOLOV <dmytropostolov@gmail.com>
  • Loading branch information
3 people authored Oct 18, 2024
1 parent b916bc9 commit c0f1b07
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
7 changes: 7 additions & 0 deletions .changeset/healthy-moose-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@graphql-eslint/eslint-plugin": patch
---

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.
8 changes: 2 additions & 6 deletions packages/plugin/__tests__/examples.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,10 @@ function getESLintOutput(cwd: string): ESLint.LintResult[] {
const errorOutput = stderr
.toString()
.replace(
/\(node:\d{4,5}\) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time/,
/\(node:\d{4,7}\) \[DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead./,
'',
)
.replace(
/\(node:\d{4,5}\) \[DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead./,
'',
)
.replace('(Use `node --trace-warnings ...` to show where the warning was created)', '')
.replace('(Use `node --trace-deprecation ...` to show where the warning was created)', '')
.trimEnd();
if (errorOutput) {
throw new Error(errorOutput);
Expand Down
4 changes: 1 addition & 3 deletions packages/plugin/src/meta.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
import packageJson from '../package.json' with { type: 'json' };

export const { version } = packageJson;
export const version = process.env.VERSION
1 change: 1 addition & 0 deletions packages/plugin/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const opts: Options = {
dts: true,
env: {
...(process.env.NODE_ENV && { NODE_ENV: process.env.NODE_ENV }),
VERSION: packageJson.version,
},
format: 'esm',
minifySyntax: true,
Expand Down

0 comments on commit c0f1b07

Please sign in to comment.