New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

@graphitation/embedded-document-artefact-loader

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@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, esbui


Version published
Maintainers
0
Created

@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

FAQs

Package last updated on 13 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts