Skip to content

Commit

Permalink
Merge branch 'dev' into markdalgleish/remove-v1-route-convention
Browse files Browse the repository at this point in the history
  • Loading branch information
markdalgleish authored Jul 30, 2023
2 parents 14f1ee8 + 1e19750 commit 6940b12
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
7 changes: 7 additions & 0 deletions .changeset/decouple-css-bundle-from-dev.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@remix-run/css-bundle": patch
"@remix-run/dev": patch
---
Decouple the `@remix-run/dev` package from the contents of the `@remix-run/css-bundle` package.

The contents of the `@remix-run/css-bundle` package are now entirely managed by the Remix compiler. Even though it's still recommended that your Remix dependencies all share the same version, this change ensures that there are no runtime errors when upgrading `@remix-run/dev` without upgrading `@remix-run/css-bundle`.
5 changes: 3 additions & 2 deletions packages/create-remix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@
"@types/gunzip-maybe": "^1.4.0",
"@types/node-fetch": "^2.5.7",
"@types/tar-fs": "^2.0.1",
"esbuild": "0.17.6",
"esbuild-register": "^3.3.2",
"fs-extra": "^10.0.0",
"msw": "^0.39.2",
"tiny-invariant": "^1.2.0",
"esbuild-register": "^3.3.2"
"tiny-invariant": "^1.2.0"
},
"engines": {
"node": ">=14.0.0"
Expand Down
13 changes: 4 additions & 9 deletions packages/remix-css-bundle/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
declare const __INJECT_CSS_BUNDLE_HREF__: string | undefined;

// Injected by `cssBundlePlugin`
let cssBundleHref: string | undefined =
typeof __INJECT_CSS_BUNDLE_HREF__ === "string"
? __INJECT_CSS_BUNDLE_HREF__
: undefined;

export { cssBundleHref };
// This file's contents are replaced by `cssBundlePlugin`. This file only exists
// to provide type definitions and a graceful fallback when importing this
// package outside of the Remix compiler.
export const cssBundleHref: string | undefined = undefined;
16 changes: 5 additions & 11 deletions packages/remix-dev/compiler/plugins/cssBundlePlugin.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type { Plugin } from "esbuild";
import { readFile } from "fs-extra";

import type { LazyValue } from "../lazyValue";

const pluginName = "css-bundle-update-plugin";
const pluginName = "css-bundle-plugin";
const namespace = `${pluginName}-ns`;

/**
Expand Down Expand Up @@ -38,19 +37,14 @@ export function cssBundlePlugin(refs: {
};
});

build.onLoad({ filter: /.*/, namespace }, async (args) => {
build.onLoad({ filter: /.*/, namespace }, async () => {
let cssBundleHref = await refs.lazyCssBundleHref.get();

let contents = await readFile(args.path, "utf8");

contents = contents.replace(
/__INJECT_CSS_BUNDLE_HREF__/g,
cssBundleHref ? JSON.stringify(cssBundleHref) : "undefined"
);

return {
loader: "js",
contents,
contents: `export const cssBundleHref = ${
cssBundleHref ? JSON.stringify(cssBundleHref) : "undefined"
};`,
};
});
},
Expand Down

0 comments on commit 6940b12

Please # to comment.