forked from jimp-dev/jimp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update file-type to disable eval dynamic code errors during build
close jimp-dev#1361
- Loading branch information
Showing
7 changed files
with
900 additions
and
119 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 |
---|---|---|
|
@@ -8,8 +8,8 @@ | |
"scripts": { | ||
"lint": "eslint .", | ||
"test-off": "vitest", | ||
"build": "tshy", | ||
"dev": "tshy --watch", | ||
"build": "tsup", | ||
"dev": "tsup --watch", | ||
"clean": "rm -rf node_modules .tshy .tshy-build dist .turbo" | ||
}, | ||
"author": "Andrew Lisowski <[email protected]>", | ||
|
@@ -20,7 +20,7 @@ | |
"@jimp/utils": "workspace:*", | ||
"await-to-js": "^3.0.0", | ||
"exif-parser": "^0.1.12", | ||
"file-type": "^16.0.0", | ||
"file-type": "^19.6.0", | ||
"mime": "3" | ||
}, | ||
"devDependencies": { | ||
|
@@ -32,6 +32,7 @@ | |
"@types/node": "^18.19.48", | ||
"eslint": "^9.9.1", | ||
"tshy": "^3.0.2", | ||
"tsup": "^8.3.5", | ||
"typescript": "^5.5.4", | ||
"vite-plugin-node-polyfills": "^0.22.0", | ||
"vitest": "^2.0.5" | ||
|
@@ -49,21 +50,21 @@ | |
"./package.json": "./package.json", | ||
".": { | ||
"import": { | ||
"types": "./dist/esm/index.d.ts", | ||
"default": "./dist/esm/index.js" | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
}, | ||
"require": { | ||
"types": "./dist/commonjs/index.d.ts", | ||
"default": "./dist/commonjs/index.js" | ||
"types": "./dist/index.d.cts", | ||
"default": "./dist/index.cjs" | ||
} | ||
} | ||
}, | ||
"main": "./dist/commonjs/index.js", | ||
"types": "./dist/commonjs/index.d.ts", | ||
"main": "./dist/index.cjs", | ||
"types": "./dist/index.d.cts", | ||
"type": "module", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"sideEffects": false, | ||
"module": "./dist/esm/index.js" | ||
"module": "./dist/index.js" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type { fileTypeFromBuffer as fileTypeFromBufferCore } from 'file-type/core' | ||
|
||
export const fileTypeFromBuffer: typeof fileTypeFromBufferCore = async ( | ||
buffer, | ||
) => { | ||
const { fileTypeFromBuffer } = await import('file-type/core') | ||
return await fileTypeFromBuffer(buffer) | ||
} |
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 @@ | ||
export { fileTypeFromBuffer } from 'file-type/core' |
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 |
---|---|---|
@@ -1,6 +1,11 @@ | ||
{ | ||
"extends": "@jimp/config-typescript/base.json", | ||
"compilerOptions": { | ||
"outDir": "dist" | ||
"outDir": "dist", | ||
"module": "ESNext", | ||
"moduleResolution": "bundler", | ||
"paths": { | ||
"#file-type/core": ["./src/polyfills/esm.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 @@ | ||
import { defineConfig } from 'tsup' | ||
|
||
export default defineConfig({ | ||
entry: ['src/index.ts'], | ||
format: ['esm', 'cjs'], | ||
dts: true, | ||
clean: true, | ||
esbuildOptions(options) { | ||
options.alias = { | ||
'#file-type/core': | ||
options.format === 'esm' | ||
? './src/polyfills/esm.ts' | ||
: './src/polyfills/cjs.ts', | ||
} | ||
}, | ||
}) |
Oops, something went wrong.