Skip to content

Commit

Permalink
feat: remove als and fs polyfills
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmpinto committed Oct 24, 2024
1 parent 6a32a76 commit 836b8f4
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 386 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fleek-platform/functions-esbuild-config",
"version": "0.0.8",
"version": "0.0.9",
"description": "ESBuild config for Fleek Functions",
"module": "./dist/index.js",
"main": "./dist/index.js",
Expand Down Expand Up @@ -37,7 +37,7 @@
"node": ">=18"
},
"peerDependencies": {
"esbuild": "^0.24.0"
"esbuild": ">=0.18.0"
},
"devDependencies": {
"@commitlint/cli": "^19.3.0",
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { BuildOptions, Plugin } from 'esbuild';
import path from 'node:path';
import { moduleChecker } from './plugins/moduleChecker.js';
import { asyncLocalStoragePolyfill } from './plugins/asyncLocalStoragePolyfill.js';
import { nodeProtocolImportSpecifier } from './plugins/nodeProtocolImportSpecifier.js';
import { fsPolyfill } from './plugins/fsPolyfill.js';

export interface FleekBuildOptions {
filePath: string;
Expand Down Expand Up @@ -35,7 +33,7 @@ export const createFleekBuildConfig = (options: FleekBuildOptions): BuildOptions
const plugins: Plugin[] = [moduleChecker({ unsupportedModulesUsed })];

if (bundle) {
plugins.push(asyncLocalStoragePolyfill(), fsPolyfill(), nodeProtocolImportSpecifier({ onError }));
plugins.push(nodeProtocolImportSpecifier({ onError }));
}

const buildOptions: BuildOptions = {
Expand All @@ -48,10 +46,14 @@ export const createFleekBuildConfig = (options: FleekBuildOptions): BuildOptions
};

buildOptions.banner = {
js: `import { Buffer } from "node:buffer";
js: `
import { Buffer } from "node:buffer";
import { AsyncLocalStorage } from "node:async_hooks";
globalThis.AsyncLocalStorage = AsyncLocalStorage;
globalThis.fleek={env:{${Object.entries(env)
.map(([key, value]) => `${key}: "${value}"`)
.join(',')}}};`,
.join(',')}}};
`,
};

return buildOptions;
Expand Down
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export { defaultOptions, createFleekBuildConfig } from './config.js';
export { moduleChecker } from './plugins/moduleChecker.js';
export { asyncLocalStoragePolyfill } from './plugins/asyncLocalStoragePolyfill.js';
export { nodeProtocolImportSpecifier } from './plugins/nodeProtocolImportSpecifier.js';
export { fsPolyfill } from './plugins/fsPolyfill.js';
export { supportedRuntimeModules, unsupportedRuntimeModules } from './runtimeModules.js';
32 changes: 0 additions & 32 deletions src/plugins/asyncLocalStoragePolyfill.ts

This file was deleted.

28 changes: 0 additions & 28 deletions src/plugins/fsPolyfill.ts

This file was deleted.

83 changes: 0 additions & 83 deletions src/plugins/polyfills/async_hooks.js

This file was deleted.

Loading

0 comments on commit 836b8f4

Please sign in to comment.