Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support webpack 5 #17

Closed
AdrienLemaire opened this issue Nov 4, 2020 · 1 comment
Closed

Support webpack 5 #17

AdrienLemaire opened this issue Nov 4, 2020 · 1 comment
Labels
wontfix This will not be worked on

Comments

@AdrienLemaire
Copy link

AdrienLemaire commented Nov 4, 2020

When trying to upgrade my project to webpack 5, it seems to fail with ts-tranform-graphql-tag.

(node:1904777) [DEP_WEBPACK_COMPILATION_ASSETS] DeprecationWarning: Compilation.assets will be frozen in future, all modifications are deprecated.
BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
        Do changes to assets earlier, e. g. in Compilation.hooks.processAssets.
        Make sure to select an appropriate stage from Compilation.PROCESS_ASSETS_STAGE_*.
(node:1904777) [DEP_WEBPACK_MODULE_ID] DeprecationWarning: Module.id: Use new ChunkGraph API
✖ 「wdm」: ModuleNotFoundError: Module not found: Error: Can't resolve './graphql' in '/home/dori/Projects/Work/Project/v3/client/node_modules/graphql'
Did you mean 'graphql.js'?
BREAKING CHANGE: The request './graphql' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
    at /home/dori/Projects/Work/Project/v3/client/node_modules/webpack/lib/Compilation.js:1478:28
    at /home/dori/Projects/Work/Project/v3/client/node_modules/webpack/lib/NormalModuleFactory.js:648:13
    at eval (eval at create (/home/dori/Projects/Work/Project/v3/client/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:10:1)
    at /home/dori/Projects/Work/Project/v3/client/node_modules/webpack/lib/NormalModuleFactory.js:233:22
    at eval (eval at create (/home/dori/Projects/Work/Project/v3/client/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
    at /home/dori/Projects/Work/Project/v3/client/node_modules/webpack/lib/NormalModuleFactory.js:357:22
    at /home/dori/Projects/Work/Project/v3/client/node_modules/webpack/lib/NormalModuleFactory.js:116:11
    at /home/dori/Projects/Work/Project/v3/client/node_modules/webpack/lib/NormalModuleFactory.js:577:24
    at /home/dori/Projects/Work/Project/v3/client/node_modules/webpack/lib/NormalModuleFactory.js:715:10
    at finishResolved (/home/dori/Projects/Work/Project/v3/client/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:278:11)
✖ 「wdm」: resolve './graphql' in '/home/dori/Projects/Work/Project/v3/client/node_modules/graphql'
  using description file: /home/dori/Projects/Work/Project/v3/client/node_modules/graphql/package.json (relative path: .)
    Field 'browser' doesn't contain a valid alias configuration
    using description file: /home/dori/Projects/Work/Project/v3/client/node_modules/graphql/package.json (relative path: ./graphql)
      Field 'browser' doesn't contain a valid alias configuration
      /home/dori/Projects/Work/Project/v3/client/node_modules/graphql/graphql doesn't exist

Using ts-tranform-graphql-tag 0.2.1

I tried adding fullySpecified: false as recommended in this thread

  {
    test: /\.tsx?$/,
    exclude: /node_modules/,
    resolve: {
      // FIXME: graphql resolution
      // https://github.com/graphql/graphql-js/issues/2721
      fullySpecified: false,
    },
    use: [
      {
        loader: "babel-loader",
        options: {
          presets: ["@babel/preset-typescript", "@babel/preset-react"],
          // used to auto-generate proptypes from typescript in dev mode
          plugins: [
            [
              "babel-plugin-typescript-to-proptypes",
              { comments: true, strict: true },
            ],
          ],
        },
      },
      {
        loader: "ts-loader",
        options: {
          getCustomTransformers: () => ({ before: [getTransformer()] }), // compile AST queries
        },
      },
    ],
  },

Which gives me different errors:

(node:1908967) [DEP_WEBPACK_COMPILATION_ASSETS] DeprecationWarning: Compilation.assets will be frozen in future, all modifications are deprecated.
BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
        Do changes to assets earlier, e. g. in Compilation.hooks.processAssets.
        Make sure to select an appropriate stage from Compilation.PROCESS_ASSETS_STAGE_*.
(node:1908967) [DEP_WEBPACK_MODULE_ID] DeprecationWarning: Module.id: Use new ChunkGraph API
✖ 「wdm」: ModuleNotFoundError: Module not found: Error: Can't resolve './version' in '/home/dori/Projects/Work/Project/v3/client/node_modules/graphql'
Did you mean 'version.js'?
BREAKING CHANGE: The request './version' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
    at /home/dori/Projects/Work/Project/v3/client/node_modules/webpack/lib/Compilation.js:1478:28
    at /home/dori/Projects/Work/Project/v3/client/node_modules/webpack/lib/NormalModuleFactory.js:648:13
    at eval (eval at create (/home/dori/Projects/Work/Project/v3/client/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:10:1)
    at /home/dori/Projects/Work/Project/v3/client/node_modules/webpack/lib/NormalModuleFactory.js:233:22
    at eval (eval at create (/home/dori/Projects/Work/Project/v3/client/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
    at /home/dori/Projects/Work/Project/v3/client/node_modules/webpack/lib/NormalModuleFactory.js:357:22
    at /home/dori/Projects/Work/Project/v3/client/node_modules/webpack/lib/NormalModuleFactory.js:116:11
    at /home/dori/Projects/Work/Project/v3/client/node_modules/webpack/lib/NormalModuleFactory.js:577:24
    at /home/dori/Projects/Work/Project/v3/client/node_modules/webpack/lib/NormalModuleFactory.js:715:10
    at finishResolved (/home/dori/Projects/Work/Project/v3/client/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:278:11)
✖ 「wdm」: resolve './version' in '/home/dori/Projects/Work/Project/v3/client/node_modules/graphql'
  using description file: /home/dori/Projects/Work/Project/v3/client/node_modules/graphql/package.json (relative path: .)
    Field 'browser' doesn't contain a valid alias configuration
    using description file: /home/dori/Projects/Work/Project/v3/client/node_modules/graphql/package.json (relative path: ./version)
      Field 'browser' doesn't contain a valid alias configuration
      /home/dori/Projects/Work/Project/v3/client/node_modules/graphql/version doesn't exist

This might be related to this issue: graphql/graphql-js#2721

@firede
Copy link
Owner

firede commented Nov 4, 2020

Hi, @AdrienLemaire
I found that you are using babel-loader, I suggest you use babel-plugin-graphql-tag instead.

@firede firede closed this as completed Nov 4, 2020
@firede firede added the wontfix This will not be worked on label Nov 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants