-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from frysztak/release/v0.4.0
v0.4.0 into master
- Loading branch information
Showing
69 changed files
with
3,562 additions
and
2,545 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
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 |
---|---|---|
|
@@ -11,11 +11,11 @@ | |
"devDependencies": { | ||
"cross-env": "^7.0.3", | ||
"husky": "^8.0.1", | ||
"lerna": "^5.0.0", | ||
"lint-staged": "^12.5.0", | ||
"lerna": "^5.1.1", | ||
"lint-staged": "^13.0.1", | ||
"prettier": "^2.6.2", | ||
"rimraf": "^3.0.2", | ||
"typescript": "^4.7.2", | ||
"typescript": "^4.7.3", | ||
"yarn-audit-fix": "^9.3.1" | ||
}, | ||
"workspaces": { | ||
|
@@ -33,5 +33,5 @@ | |
"*.{js,cjs,css,md,ts,tsx,json,yml,yaml}": "prettier --write" | ||
}, | ||
"packageManager": "[email protected]", | ||
"version": "0.3.0" | ||
"version": "0.4.0" | ||
} |
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,15 @@ | ||
import { build } from 'esbuild'; | ||
import { jsdomPlugin } from './jsdom.js'; | ||
import { nativeNodeModulesPlugin } from './native-node-module.js'; | ||
|
||
build({ | ||
entryPoints: ['server.ts'], | ||
bundle: true, | ||
minify: true, | ||
outdir: 'dist', | ||
outExtension: { '.js': '.cjs' }, | ||
platform: 'node', | ||
target: ['node16'], | ||
external: ['pg-native', 'canvas', 'pino'], | ||
plugins: [jsdomPlugin(), nativeNodeModulesPlugin()], | ||
}).catch((err) => process.exit(1)); |
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,27 @@ | ||
import fs from 'fs'; | ||
import { createRequire } from 'module'; | ||
|
||
export const jsdomPlugin = () => { | ||
const require = createRequire(import.meta.url); | ||
|
||
return { | ||
name: 'jsdom-patch', | ||
setup(build) { | ||
build.onLoad( | ||
{ filter: /jsdom\/living\/xhr\/XMLHttpRequest-impl\.js$/ }, | ||
async (args) => { | ||
let contents = await fs.promises.readFile(args.path, 'utf8'); | ||
|
||
contents = contents.replace( | ||
'const syncWorkerFile = require.resolve ? require.resolve("./xhr-sync-worker.js") : null;', | ||
`const syncWorkerFile = "${require.resolve( | ||
'jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js' | ||
)}";` | ||
); | ||
|
||
return { contents, loader: '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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// https://raw.githubusercontent.com/egoist/tsup/dev/src/esbuild/native-node-module.ts | ||
import path from 'path'; | ||
import { createRequire } from 'module'; | ||
|
||
// Copied from https://github.com/evanw/esbuild/issues/1051#issuecomment-806325487 | ||
export const nativeNodeModulesPlugin = () => { | ||
const require = createRequire(import.meta.url); | ||
|
||
return { | ||
name: 'native-node-modules', | ||
setup(build) { | ||
// If a ".node" file is imported within a module in the "file" namespace, resolve | ||
// it to an absolute path and put it into the "node-file" virtual namespace. | ||
build.onResolve({ filter: /\.node$/, namespace: 'file' }, (args) => { | ||
const resolvedId = require.resolve(args.path, { | ||
paths: [args.resolveDir], | ||
}); | ||
if (resolvedId.endsWith('.node')) { | ||
return { | ||
path: resolvedId, | ||
namespace: 'node-file', | ||
}; | ||
} | ||
return { | ||
path: resolvedId, | ||
}; | ||
}); | ||
|
||
// Files in the "node-file" virtual namespace call "require()" on the | ||
// path from esbuild of the ".node" file in the output directory. | ||
build.onLoad({ filter: /.*/, namespace: 'node-file' }, (args) => { | ||
return { | ||
contents: ` | ||
import path from ${JSON.stringify(args.path)} | ||
try { module.exports = require(path) } | ||
catch {} | ||
`, | ||
resolveDir: path.dirname(args.path), | ||
}; | ||
}); | ||
|
||
// If a ".node" file is imported within a module in the "node-file" namespace, put | ||
// it in the "file" namespace where esbuild's default loading behavior will handle | ||
// it. It is already an absolute path since we resolved it to one above. | ||
build.onResolve( | ||
{ filter: /\.node$/, namespace: 'node-file' }, | ||
(args) => ({ | ||
path: args.path, | ||
namespace: 'file', | ||
}) | ||
); | ||
|
||
// Tell esbuild's default loading behavior to use the "file" loader for | ||
// these ".node" files. | ||
const opts = build.initialOptions; | ||
opts.loader = opts.loader || {}; | ||
opts.loader['.node'] = 'file'; | ||
}, | ||
}; | ||
}; |
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
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
Oops, something went wrong.