luckycatfactory / esbuild-graphql-loader

An esbuild Plugin Allowing for GraphQL File imports
44 stars 8 forks source link

Import statement not resolved #34

Open Tjerk-Haaye-Henricus opened 1 year ago

Tjerk-Haaye-Henricus commented 1 year ago

Hey there 👋

This code:

// result.ts
import * as createEvent from './createEvent.graphql';

with this configuration:

const graphqlLoaderPluginInstance = graphqlLoaderPlugin({
  mapDocumentNode: (documentNode: DocumentNode) =>
    optimizeDocumentNode(documentNode),
})

build({
  entryPoints: files,
  format: 'cjs',
  outdir: 'dist/cjs',
  jsx: 'transform',
  bundle: false,
  minify: isProduction,
  sourcemap: !isProduction,
  platform: 'node',
  target,
  plugins: [graphqlLoaderPluginInstance],
}).catch((error) => {
  console.log(error)
  process.exit(1)
})

results in

// result.js
var createEvent = __toESM(require("./createEvent.graphql"));

Shouldn't the .graphql file be bundled into the request.ts A example project would help me a lot understanding what should we the result.