Skip to content

xdm webpack loader doesn’t work with webpack cli #11

@remcohaszing

Description

@remcohaszing

The issue can be reproduced from within this repository. I use Webpack 4, but the same issue can be reproduced using Webpack 5.

In this repository, add the following files:

webpack.config.cjs:

module.exports = {
  module: {
    rules: [
      {
        test: /\.mdx?$/,
        loader: require.resolve('./webpack.cjs')
      }
    ]
  }
};

src/index.js:

import './foo.md'

src/foo.md:

<Hello />

Now running the following command yields an error:

$ yarn webpack --mode production

The first time the following error is thrown:

(node:619531) UnhandledPromiseRejectionWarning: TypeError [ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING]: A dynamic import callback was not specified.
    at exports.importModuleDynamicallyCallback (internal/process/esm_loader.js:34:9)
    at Object.module.exports (/home/remco/Projects/xdm/webpack.cjs:14:3)
    at LOADER_EXECUTION (/home/remco/Projects/xdm/node_modules/loader-runner/lib/LoaderRunner.js:132:14)
    at runSyncOrAsync (/home/remco/Projects/xdm/node_modules/loader-runner/lib/LoaderRunner.js:133:4)
    at iterateNormalLoaders (/home/remco/Projects/xdm/node_modules/loader-runner/lib/LoaderRunner.js:250:2)
    at Array.<anonymous> (/home/remco/Projects/xdm/node_modules/loader-runner/lib/LoaderRunner.js:223:4)
    at runCallbacks (/home/remco/Projects/xdm/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:27:15)
    at /home/remco/Projects/xdm/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:200:4
    at /home/remco/Projects/xdm/node_modules/graceful-fs/graceful-fs.js:123:16
    at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:63:3)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:619531) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:619531) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

After a retry, this error is thrown:

(node:620590) UnhandledPromiseRejectionWarning: TypeError: Invalid host defined options
    at Object.module.exports (/home/remco/Projects/xdm/webpack.cjs:14:3)
    at LOADER_EXECUTION (/home/remco/Projects/xdm/node_modules/loader-runner/lib/LoaderRunner.js:132:14)
    at runSyncOrAsync (/home/remco/Projects/xdm/node_modules/loader-runner/lib/LoaderRunner.js:133:4)
    at iterateNormalLoaders (/home/remco/Projects/xdm/node_modules/loader-runner/lib/LoaderRunner.js:250:2)
    at Array.<anonymous> (/home/remco/Projects/xdm/node_modules/loader-runner/lib/LoaderRunner.js:223:4)
    at runCallbacks (/home/remco/Projects/xdm/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:27:15)
    at /home/remco/Projects/xdm/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:200:4
    at /home/remco/Projects/xdm/node_modules/graceful-fs/graceful-fs.js:123:16
    at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:63:3)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:620590) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:620590) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Afterwards the errors seem to alternate randomly.

I did not run into this issue when using koa-webpack. This may explain why this issue isn’t caught by any tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions