Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync bun-polyfills branch #4081

Merged
merged 52 commits into from
Aug 10, 2023
Merged
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
a4b396f
bun-polyfills: initial impl. & baseline refactor
jhmaster2000 Jul 27, 2023
07faf81
move @types/ws dep from root to /test/
jhmaster2000 Jul 27, 2023
6dbd31e
bun-types: remove ReadableStream.forEach method
jhmaster2000 Jul 27, 2023
d7bb223
bun-polyfills: remove extraneous stream utils
jhmaster2000 Jul 27, 2023
db013ba
bun-polyfills: add types syncing file
jhmaster2000 Jul 27, 2023
954a0de
bun-polyfills: re-arrange global polyfills
jhmaster2000 Jul 27, 2023
f20a55b
bun-polyfills: fix FileBlob streams types again
jhmaster2000 Jul 27, 2023
9e286ec
bun-polyfills: sync all of @types/node
jhmaster2000 Jul 27, 2023
4fe1190
bun-polyfills: typeguard all current polyfills
jhmaster2000 Jul 27, 2023
4a29ff5
bun-polyfills: fix import paths
jhmaster2000 Jul 27, 2023
ea8696a
bun-polyfills: switch to wasm impl. of farmhash
jhmaster2000 Jul 28, 2023
938935f
bun-polyfills: support default import of bun obj
jhmaster2000 Jul 28, 2023
aac66cb
bun-polyfills: transpiler placeholder file
jhmaster2000 Jul 28, 2023
18e176e
bun-polyfills: loaderless import.meta polyfill
jhmaster2000 Jul 28, 2023
8137f55
bun-polyfills: refactor import.meta polyfill
jhmaster2000 Jul 29, 2023
d18aca6
bun-polyfills: repl entrypoint & todo list index
jhmaster2000 Jul 29, 2023
efeb4af
bun-types: Add null to return type of Bun.which
jhmaster2000 Aug 1, 2023
3205c24
bun-types: match Bun.sha with Bun.hash.SHA512_256
jhmaster2000 Aug 1, 2023
9d60813
bun-polyfills: new "repl" package.json script
jhmaster2000 Aug 1, 2023
b2a15dc
bun-polyfills: full refactor of toplevel hashes
jhmaster2000 Aug 1, 2023
4b5d3c6
bun-polyfills: these are fixed
jhmaster2000 Aug 2, 2023
147ba05
bun-types: NODE_ENV is optional
jhmaster2000 Aug 2, 2023
3cccba0
bun-polyfills: fix Bun.env types
jhmaster2000 Aug 2, 2023
0a54cc8
bun-types+polyfills: fix HeapSnapshot.version type
jhmaster2000 Aug 2, 2023
aa1963d
bun-polyfills: fix some web streams type conflicts
jhmaster2000 Aug 2, 2023
687035d
bun-polyfills: update internal FileBlob.slice
jhmaster2000 Aug 2, 2023
36af41a
bun-polyfills: fix subproc stdin conversions
jhmaster2000 Aug 2, 2023
35426dc
bun-polyfills: better internal fileblob types
jhmaster2000 Aug 3, 2023
df4d6a9
bun-polyfills: try to sync global performance type
jhmaster2000 Aug 3, 2023
9aaa110
bun-polyfills: working zig wasm polyfills setup
jhmaster2000 Aug 3, 2023
4317fd6
bun-polyfills: update scripts
jhmaster2000 Aug 3, 2023
cbe4905
bun-polyfills: fix wasm file location resolution
jhmaster2000 Aug 3, 2023
5a7d990
bun-polyfills: goodbye farmhash (replaced by zig)
jhmaster2000 Aug 4, 2023
af9eaf1
bun-polyfills: move all Bun.hash polyfills to zig
jhmaster2000 Aug 4, 2023
5e09e80
bun-polyfills: reimpl. seeding of seeded hashes
jhmaster2000 Aug 4, 2023
350c09b
bun-polyfills: impl. undocumented murmur32v2
jhmaster2000 Aug 4, 2023
c8bc826
bun-polyfills: switch zighash from jsdoc to .d.ts
jhmaster2000 Aug 4, 2023
1c86afa
bun-types: partial fix of Hash types
jhmaster2000 Aug 5, 2023
d52d676
bun-polyfills: documented Hash.murmur32v2
jhmaster2000 Aug 5, 2023
d60b601
Merge branch 'main' into bun-polyfills
jhmaster2000 Aug 9, 2023
29af5d7
Merge branch 'main' into bun-polyfills
jhmaster2000 Aug 9, 2023
844c7fe
bun-polyfills: misc updates
jhmaster2000 Aug 9, 2023
1ec483d
bun-polyfills: enable sourcemaps
jhmaster2000 Aug 9, 2023
4f3ec7b
bun-polyfills: handle empty inputs to hash funcs
jhmaster2000 Aug 9, 2023
cf1b5dd
bun-types: narrow down hash func types
jhmaster2000 Aug 9, 2023
e395149
bun-polyfills: remove unnecessary bigint casts
jhmaster2000 Aug 9, 2023
feb8b1f
bun-polyfills: impl. Bun.isMainThread
jhmaster2000 Aug 9, 2023
66b1abd
bun-polyfills: impl. Bun.sleep and fix sleepSync
jhmaster2000 Aug 9, 2023
a80eb13
bun-polyfills: impl. indexOfLine
jhmaster2000 Aug 9, 2023
de6e020
bun-polyfills: impl. Bun.peek.status
jhmaster2000 Aug 9, 2023
9d1add2
Merge branch 'main' into bun-polyfills
Jarred-Sumner Aug 9, 2023
358d8ff
bun-types: fix hashing test
jhmaster2000 Aug 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
bun-polyfills: refactor import.meta polyfill
  • Loading branch information
jhmaster2000 committed Jul 29, 2023
commit 8137f552b9647a12a52d946c2f542aaceab90de0
34 changes: 21 additions & 13 deletions packages/bun-polyfills/src/global/importmeta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,25 @@ import { createRequire } from 'node:module';
// the top of every module file bundled.

export default function polyfillImportMeta(metaIn: ImportMeta) {
const require = createRequire(metaIn.url);
const meta = metaIn as Mutable<ImportMeta>;

meta.path = fileURLToPath(meta.url);
meta.dir = path.dirname(meta.path);
meta.file = path.basename(meta.path);
meta.require = require;
meta.resolve = async (id: string, parent?: string) => meta.resolveSync(id, parent);
meta.resolveSync = (id: string, parent?: string) => require.resolve(id, {
paths: typeof parent === 'string' ? [
path.resolve(parent.startsWith('file://') ? fileURLToPath(parent) : parent, '..')
] : undefined,
});
const require2 = createRequire(metaIn.url);
const metapath = fileURLToPath(metaIn.url);
const meta: ImportMeta = {
url: metaIn.url,
main: metapath === process.argv[1],
path: metapath,
dir: path.dirname(metapath),
file: path.basename(metapath),
require: require2,
async resolve(id: string, parent?: string) {
return this.resolveSync(id, parent);
},
resolveSync(id: string, parent?: string) {
return require2.resolve(id, {
paths: typeof parent === 'string' ? [
path.resolve(parent.startsWith('file://') ? fileURLToPath(parent) : parent, '..')
] : undefined,
});
},
};
Object.assign(metaIn, meta);
}