Skip to content

Commit

Permalink
fix(dev): allow decorators in app code during dev (#7176)
Browse files Browse the repository at this point in the history
  • Loading branch information
pcattori authored Aug 15, 2023
1 parent c114621 commit ba67f42
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/khaki-roses-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/dev": patch
---

allow decorators in app code
8 changes: 7 additions & 1 deletion packages/remix-dev/compiler/js/plugins/hmr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ export async function applyHMR(
let babelJsx = await import("@babel/plugin-syntax-jsx");
// @ts-expect-error
let reactRefresh = await import("react-refresh/babel");
// @ts-expect-error
let babelDecorators = await import("@babel/plugin-syntax-decorators");

let IS_FAST_REFRESH_ENABLED = /\$RefreshReg\$\(/;

Expand Down Expand Up @@ -195,7 +197,11 @@ ${lastModified ? `import.meta.hot.lastModified = "${lastModified}";` : ""}
configFile: false,
babelrc: false,
presets: [babelPresetTypescript.default],
plugins: [babelJsx.default, [reactRefresh.default, { skipEnvCheck: true }]],
plugins: [
[babelDecorators.default, { legacy: true }],
babelJsx.default,
[reactRefresh.default, { skipEnvCheck: true }],
],
});

let jsWithReactRefresh = transformResult?.code ?? sourceCodeWithHMR;
Expand Down
3 changes: 2 additions & 1 deletion packages/remix-dev/devServer_unstable/proc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ let isAlive = (pid: number) => {
};

export let killtree = async (pid: number) => {
let descendants = await pidtree(pid);
let descendants = await pidtree(pid).catch(() => undefined);
if (descendants === undefined) return;
let pids = [pid, ...descendants];

await Promise.all(pids.map(kill));
Expand Down
1 change: 1 addition & 0 deletions packages/remix-dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@babel/core": "^7.21.8",
"@babel/generator": "^7.21.5",
"@babel/parser": "^7.21.8",
"@babel/plugin-syntax-decorators": "^7.22.10",
"@babel/plugin-syntax-jsx": "^7.21.4",
"@babel/plugin-syntax-typescript": "^7.21.4",
"@babel/preset-typescript": "^7.21.5",
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@
resolved "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.21.5.tgz#345f2377d05a720a4e5ecfa39cbf4474a4daed56"
integrity sha512-0WDaIlXKOX/3KfBK/dwP1oQGiPh6rjMkT7HIRv7i5RR2VUMwrx5ZL0dwBkKx7+SW1zwNdgjHd34IMk5ZjTeHVg==

"@babel/helper-plugin-utils@^7.22.5":
version "7.22.5"
resolved "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.22.5.tgz#dd7ee3735e8a313b9f7b05a773d892e88e6d7295"
integrity sha512-uLls06UVKgFG9QD4OeFYLEGteMIAa5kpTPcFL28yuCIIzsf6ZyKZMllKVOCZFhiZ5ptnwX4mtKdWCBE/uT4amg==

"@babel/helper-remap-async-to-generator@^7.18.9":
version "7.18.9"
resolved "https://registry.npmjs.org/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.18.9.tgz#997458a0e3357080e54e1d79ec347f8a8cd28519"
Expand Down Expand Up @@ -473,6 +478,13 @@
dependencies:
"@babel/helper-plugin-utils" "^7.14.5"

"@babel/plugin-syntax-decorators@^7.22.10":
version "7.22.10"
resolved "https://registry.npmjs.org/@babel/plugin-syntax-decorators/-/plugin-syntax-decorators-7.22.10.tgz#7d83ea04d893c442b78ebf4c3cbac59a7211deff"
integrity sha512-z1KTVemBjnz+kSEilAsI4lbkPOl5TvJH7YDSY1CTIzvLWJ+KHXp+mRe8VPmfnyvqOPqar1V2gid2PleKzRUstQ==
dependencies:
"@babel/helper-plugin-utils" "^7.22.5"

"@babel/plugin-syntax-dynamic-import@^7.8.3":
version "7.8.3"
resolved "https://registry.npmjs.org/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.8.3.tgz"
Expand Down

0 comments on commit ba67f42

Please sign in to comment.