Skip to content

Commit

Permalink
remove --polyfill-node / config.polyfill_node (#100)
Browse files Browse the repository at this point in the history
* remove `polyfill-node` / `polyfill_node`

The quality of the polyfills is quite bad, so I'm removing this implementation (introduced in  #72)

* add a changeset

* Update package-lock.json
  • Loading branch information
threepointone authored Dec 13, 2021
1 parent 7858ca2 commit 2f760f5
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 231 deletions.
5 changes: 5 additions & 0 deletions .changeset/neat-timers-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

remove `--polyfill-node`
160 changes: 0 additions & 160 deletions package-lock.json

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

4 changes: 1 addition & 3 deletions packages/wrangler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
"esbuild": "0.14.1",
"miniflare": "2.0.0-rc.3",
"semiver": "^1.1.0",
"serve": "^13.0.2",
"@esbuild-plugins/node-globals-polyfill": "^0.1.1",
"@esbuild-plugins/node-modules-polyfill": "^0.1.2"
"serve": "^13.0.2"
},
"optionalDependencies": {
"fsevents": "~2.3.2"
Expand Down
9 changes: 1 addition & 8 deletions packages/wrangler/scripts/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@ async function run() {
platform: "node",
format: "cjs",
// minify: true, // TODO: enable this again
external: [
"fsevents",
"esbuild",
"miniflare",
"@miniflare/core",
"@esbuild-plugins/node-globals-polyfill",
"@esbuild-plugins/node-modules-polyfill",
], // todo - bundle miniflare too
external: ["fsevents", "esbuild", "miniflare", "@miniflare/core"], // todo - bundle miniflare too
sourcemap: true,
inject: [path.join(__dirname, "../import_meta_url.js")],
define: {
Expand Down
2 changes: 0 additions & 2 deletions packages/wrangler/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ type Env = {
site?: Site;
jsx_factory?: string; // inherited
jsx_fragment?: string; // inherited
polyfill_node?: boolean; //inherited
// we should use typescript to parse cron patterns
triggers?: { crons: Cron[] }; // inherited
vars?: Vars;
Expand All @@ -108,7 +107,6 @@ export type Config = {
webpack_config?: string; // inherited
jsx_factory?: string; // inherited
jsx_fragment?: string; // inherited
polyfill_node?: boolean; //inherited
vars?: Vars;
migrations?: DOMigration[];
durable_objects?: { bindings: DurableObject[] };
Expand Down
22 changes: 2 additions & 20 deletions packages/wrangler/src/dev.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import commandExists from "command-exists";
import assert from "assert";
import { getAPIToken } from "./user";
import fetch from "node-fetch";
import NodeModulesPolyfills from "@esbuild-plugins/node-modules-polyfill";
import NodeGlobalsPolyfills from "@esbuild-plugins/node-globals-polyfill";

type CfScriptFormat = void | "modules" | "service-worker";

Expand All @@ -42,7 +40,6 @@ type Props = {
compatibilityDate: void | string;
compatibilityFlags: void | string[];
usageModel: void | "bundled" | "unbound";
polyfillNode: void | boolean;
};

export function Dev(props: Props): JSX.Element {
Expand All @@ -61,7 +58,6 @@ export function Dev(props: Props): JSX.Element {
staticRoot: props.public,
jsxFactory: props.jsxFactory,
jsxFragment: props.jsxFragment,
polyfillNode: props.polyfillNode,
});
if (bundle && bundle.type === "commonjs" && !props.format && props.public) {
throw new Error(
Expand Down Expand Up @@ -355,26 +351,15 @@ function useEsbuild(props: {
staticRoot: void | string;
jsxFactory: string | void;
jsxFragment: string | void;
polyfillNode: boolean | void;
}): EsbuildBundle | void {
const {
entry,
destination,
staticRoot,
jsxFactory,
jsxFragment,
polyfillNode,
} = props;
const { entry, destination, staticRoot, jsxFactory, jsxFragment } = props;
const [bundle, setBundle] = useState<EsbuildBundle>();
useEffect(() => {
let result: esbuild.BuildResult;
async function build() {
if (!destination) return;
result = await esbuild.build({
entryPoints: [entry],
define: {
...(polyfillNode && { global: "globalThis" }),
},
bundle: true,
outdir: destination,
metafile: true,
Expand All @@ -383,9 +368,6 @@ function useEsbuild(props: {
loader: {
".js": "jsx",
},
plugins: polyfillNode
? [NodeGlobalsPolyfills({ buffer: true }), NodeModulesPolyfills()]
: undefined,
...(jsxFactory && { jsxFactory }),
...(jsxFragment && { jsxFragment }),
external: ["__STATIC_CONTENT_MANIFEST"],
Expand Down Expand Up @@ -418,7 +400,7 @@ function useEsbuild(props: {
return () => {
result?.stop();
};
}, [entry, destination, staticRoot, jsxFactory, jsxFragment, polyfillNode]);
}, [entry, destination, staticRoot, jsxFactory, jsxFragment]);
return bundle;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/dialogs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type PromptProps = {
onSubmit: (text: string) => void;
};

export function Prompt(props: PromptProps) {
function Prompt(props: PromptProps) {
const [value, setValue] = useState("");

return (
Expand Down
Loading

0 comments on commit 2f760f5

Please sign in to comment.