-
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bundle with tsup to strip out development code, check with bob (#1729)
- Loading branch information
1 parent
c96ced1
commit 018b2da
Showing
11 changed files
with
427 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@graphql-eslint/eslint-plugin': minor | ||
--- | ||
|
||
bundle with tsup to strip out development code, check with bob |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,32 +5,38 @@ | |
"repository": "https://github.com/B2o5T/graphql-eslint", | ||
"author": "Dotan Simha <[email protected]>", | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=12" | ||
}, | ||
"main": "dist/cjs/index.js", | ||
"module": "dist/esm/index.js", | ||
"exports": { | ||
"./package.json": "./package.json", | ||
".": { | ||
"require": { | ||
"types": "./dist/typings/index.d.cts", | ||
"types": "./dist/cjs/index.d.ts", | ||
"default": "./dist/cjs/index.js" | ||
}, | ||
"import": { | ||
"types": "./dist/typings/index.d.ts", | ||
"types": "./dist/esm/index.d.mts", | ||
"default": "./dist/esm/index.js" | ||
}, | ||
"default": { | ||
"types": "./dist/typings/index.d.ts", | ||
"types": "./dist/esm/index.d.mts", | ||
"default": "./dist/esm/index.js" | ||
} | ||
} | ||
}, | ||
"typings": "dist/typings/index.d.ts", | ||
"typings": "dist/esm/index.d.mts", | ||
"keywords": [ | ||
"eslint", | ||
"eslintplugin", | ||
"eslint-plugin", | ||
"graphql" | ||
], | ||
"scripts": { | ||
"build": "tsup" | ||
}, | ||
"peerDependencies": { | ||
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0" | ||
}, | ||
|
@@ -64,6 +70,6 @@ | |
}, | ||
"sideEffects": false, | ||
"typescript": { | ||
"definition": "dist/typings/index.d.ts" | ||
"definition": "dist/cjs/index.d.ts" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es2021", | ||
"module": "ESNext", | ||
"declaration": false, | ||
"noEmit": true, | ||
"esModuleInterop": true, | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"allowJs": true, | ||
"moduleResolution": "node", | ||
"lib": ["ESNext"], | ||
"types": ["vitest/globals"], | ||
"resolveJsonModule": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { defineConfig, Options } from 'tsup'; | ||
import fs, { readFile, writeFile } from 'node:fs/promises'; | ||
import path from 'node:path'; | ||
import packageJson from './package.json'; | ||
|
||
const opts: Options = { | ||
entry: ['src/**/*.ts'], | ||
clean: true, | ||
bundle: false, | ||
dts: true, | ||
env: { | ||
...(process.env.NODE_ENV && { NODE_ENV: process.env.NODE_ENV }), | ||
}, | ||
}; | ||
|
||
const CWD = process.cwd(); | ||
export default defineConfig([ | ||
{ | ||
...opts, | ||
format: 'esm', | ||
outDir: 'dist/esm', | ||
outExtension: () => ({ js: '.js' }), | ||
async onSuccess() { | ||
await fs.copyFile( | ||
path.join(CWD, '..', '..', 'README.md'), | ||
path.join(CWD, 'dist', 'README.md'), | ||
); | ||
await fs.writeFile(path.join(CWD, 'dist', 'esm', 'package.json'), '{"type": "module"}'); | ||
await fs.writeFile( | ||
path.join(CWD, 'dist', 'package.json'), | ||
JSON.stringify({ ...packageJson, devDependencies: undefined }).replaceAll('dist/', ''), | ||
); | ||
|
||
const filePaths = [ | ||
'estree-converter/utils.js', | ||
'rules/graphql-js-validation.js', | ||
'testkit.js', | ||
]; | ||
await Promise.all( | ||
filePaths.map(async filePath => { | ||
const fullPath = path.join(CWD, 'dist', 'esm', filePath); | ||
const content = await readFile(fullPath, 'utf8'); | ||
await writeFile( | ||
fullPath, | ||
` | ||
import { createRequire } from 'module'; | ||
const require = createRequire(import.meta.url); | ||
${content}`.trimStart(), | ||
); | ||
}), | ||
); | ||
|
||
console.log('✅ Success!'); | ||
}, | ||
}, | ||
{ | ||
...opts, | ||
format: 'cjs', | ||
outDir: 'dist/cjs', | ||
}, | ||
]); |
Oops, something went wrong.