Last active
December 1, 2021 21:29
-
-
Save cj/2c915d2729e43c8f2f4fdf2c65f60f23 to your computer and use it in GitHub Desktop.
graphql file support for remix.run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/node_modules/@remix-run/dev/compiler.js b/node_modules/@remix-run/dev/compiler.js | |
index 22c5ac0..eb1f7c4 100644 | |
--- a/node_modules/@remix-run/dev/compiler.js | |
+++ b/node_modules/@remix-run/dev/compiler.js | |
@@ -28,6 +28,7 @@ var loaders = require('./compiler/loaders.js'); | |
var mdx = require('./compiler/plugins/mdx.js'); | |
var routes = require('./compiler/routes.js'); | |
var fs$1 = require('./compiler/utils/fs.js'); | |
+var graphqlLoaderPlugin = require('@luckycatfactory/esbuild-graphql-loader').default; | |
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | |
@@ -313,7 +314,8 @@ async function createBrowserBuild(config, options) { | |
define: { | |
"process.env.NODE_ENV": JSON.stringify(options.mode) | |
}, | |
- plugins: [mdx.mdxPlugin(config), browserRouteModulesPlugin(config, /\?browser$/), emptyModulesPlugin(config, /\.server(\.[jt]sx?)?$/)] | |
+ plugins: [mdx.mdxPlugin(config), browserRouteModulesPlugin(config, /\?browser$/), emptyModulesPlugin(config, /\.server(\.*([jt]sx?)|graphql)?$/), graphqlLoaderPlugin()], | |
+ resolveExtensions: [".tsx",".ts",".jsx",".js",".css",".json", ".graphql"] | |
}); | |
} | |
@@ -338,7 +340,7 @@ async function createServerBuild(config, options) { | |
// of CSS and other files. | |
assetNames: "_assets/[name]-[hash]", | |
publicPath: config.publicPath, | |
- plugins: [mdx.mdxPlugin(config), serverRouteModulesPlugin(config), emptyModulesPlugin(config, /\.client(\.[jt]sx?)?$/), manualExternalsPlugin((id, importer) => { | |
+ plugins: [mdx.mdxPlugin(config), serverRouteModulesPlugin(config), emptyModulesPlugin(config, /\.client(\.([jt]sx?)|graphql)?$/), manualExternalsPlugin((id, importer) => { | |
// assets.json is external because this build runs in parallel with the | |
// browser build and it's not there yet. | |
if (id === "./assets.json" && importer === "<stdin>") return true; // Mark all bare imports as external. They will be require()'d at | |
@@ -357,7 +359,8 @@ async function createServerBuild(config, options) { | |
} | |
return false; | |
- })] | |
+ }), graphqlLoaderPlugin()], | |
+ resolveExtensions: [".tsx",".ts",".jsx",".js",".css",".json", ".graphql"] | |
}); | |
} | |
diff --git a/node_modules/@remix-run/dev/compiler/loaders.js b/node_modules/@remix-run/dev/compiler/loaders.js | |
index f142f3e..aecd9e7 100644 | |
--- a/node_modules/@remix-run/dev/compiler/loaders.js | |
+++ b/node_modules/@remix-run/dev/compiler/loaders.js | |
@@ -62,7 +62,8 @@ const loaders = { | |
".webm": "file", | |
".webp": "file", | |
".woff": "file", | |
- ".woff2": "file" | |
+ ".woff2": "file", | |
+ ".graphql": "file" | |
}; | |
function getLoaderForFile(file) { | |
let ext = path__namespace.extname(file); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment