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

on latest adapter-node Could not dynamically require "x". Please configure the dynamicRequireTargets #7266

Closed
gbkwiatt opened this issue Oct 14, 2022 · 4 comments

Comments

@gbkwiatt
Copy link
Contributor

Describe the bug

Another issue after migrating to latest sveltekit and adapter-node.
one of my routes, has a server route that uses shelljs it worked fine before. But now: on dev it works, but after building with adapter-node, and running server - upon navigating to that route, I get that error Error: Could not dynamically require "./src/cat". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work. Any ideas ?

Also not sure if it's related but on build with adapter node I get information about Circular dependency: ../../node_modules/.pnpm/[email protected]/node_modules/shelljs/shell.js -> ../../node_modules/.pnpm/[email protected]/node_modules/shelljs/src/common.js -> ../../node_modules/.pnpm/[email protected]/node_modules/shelljs/shell.js

Reproduction

Use shelljs module in one of the js files that route depends on.

Logs

No response

System Info

System:
    OS: Linux 5.10 Ubuntu 20.04.4 LTS (Focal Fossa)
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
    Memory: 5.42 GB / 9.72 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 18.1.0 - ~/.nvm/versions/node/v18.1.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.1.0/bin/yarn
    npm: 8.8.0 - ~/.nvm/versions/node/v18.1.0/bin/npm
  npmPackages:
    @sveltejs/adapter-auto: 1.0.0-next.80 => 1.0.0-next.80 
    @sveltejs/adapter-cloudflare: 1.0.0-next.39 => 1.0.0-next.39 
    @sveltejs/adapter-node: 1.0.0-next.98 => 1.0.0-next.98 
    @sveltejs/adapter-static: 1.0.0-next.44 => 1.0.0-next.44 
    @sveltejs/kit: 1.0.0-next.516 => 1.0.0-next.516 
    @sveltejs/package: 1.0.0-next.5 => 1.0.0-next.5 
    svelte: ^3.50.1 => 3.51.0 
    vite: ^3.1.4 => 3.1.8

Severity

blocking an upgrade

Additional Information

No response

@Conduitry
Copy link
Member

I doubt we'd want to expose all of the Rollup plugin configuration in the Node adapter configuration. If shelljs is doing something weird with dynamic requires, I'd suggest moving it from a dev dependency to a prod dependency so that Rollup doesn't try to bundle it.

@gbkwiatt
Copy link
Contributor Author

gbkwiatt commented Oct 14, 2022

It already is in prod dependancies, tried in dev dependancies and with NODE_ENV production and development but same result.
It's weird because nothing changed in that matter except adapter-node version.

Essentially what it does, it tried to require something like

commands.forEach(function (command) {
	  commonjsRequire('./src/' + command);
	});

Which does not exist after build-node

But on a previous adpater version file was just resolving to the same file without trying to do all this weird imports.

And now I get what did you mean - it bundles it into the file. But how to prevent it ?

@leroytromp
Copy link

leroytromp commented Oct 15, 2022

Probably linked to: #7216 and #7209 . Seems like adapter-node is bundling things that should be external and there is no way to stop it from doing that.

@gbkwiatt
Copy link
Contributor Author

I will close that then and monitor #7216

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants