@graphitation/embedded-document-artefact-loader
v0.8.5
Published
This is a simple set of webpack/jest loaders that will replace embedded GraphQL documents with an import of an external compiled artefact file. It is meant to remain agnostic of a specific AST form, so it can work with pipelines that use babel, tsc, esbui
Downloads
234
Keywords
Readme
@graphitation/embedded-document-artefact-loader
This is a simple set of webpack/jest loaders that will replace embedded GraphQL documents with an import of an external compiled artefact file. It is meant to remain agnostic of a specific AST form, so it can work with pipelines that use babel, tsc, esbuild, swc, etc.
It works for @graphitation/apollo-react-relay-duct-tape
and react-relay
.
webpack
const webpackConfig = {
module: {
rules: [
{
test: /.+?\.tsx?$/,
exclude: /node_modules/,
use: [
{
loader: "@graphitation/embedded-document-artefact-loader/webpack",
},
],
},
],
},
};
If you are using the artifactDirectory
option in your relay config you will need to direct the loader to the same folder.
const webpackConfig = {
module: {
rules: [
{
test: /.+?\.tsx?$/,
exclude: /node_modules/,
use: [
{
loader: "@graphitation/embedded-document-artefact-loader/webpack",
options: {
artifactDirectory: "path/to/your/artifact/directory",
},
},
],
},
],
},
};
Jest
The jest loader wraps ts-jest because there's no built-in way to chain loaders. The host still needs to provide ts-jest on their own.
const jestConfig = {
transform: {
"^.+\\.tsx?$": "@graphitation/embedded-document-artefact-loader/ts-jest",
},
};
If you are using the artifactDirectory
option in your relay config you will need to direct the loader to the same folder.
const jestConfig = {
transform: {
"^.+\\.tsx?$": [
"@graphitation/embedded-document-artefact-loader/ts-jest",
{
artifactDirectory: "path/to/your/artifact/directory",
},
],
},
};
TODO
- SourceMap support needs to be finished