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

Bug when compiling with Knex.js on windows 10 #593

Closed
code-ape opened this issue Sep 22, 2020 · 11 comments
Closed

Bug when compiling with Knex.js on windows 10 #593

code-ape opened this issue Sep 22, 2020 · 11 comments
Labels
bug Something isn't working

Comments

@code-ape
Copy link

code-ape commented Sep 22, 2020

We've run into a strange issue with code compilation by ncc resulting in a crashing program on Windows 10. A repo has been created that has been verified to exhibit this issue, here: https://github.com/urbdyn/ncc-bug-1

The bug results in code within Knex.js replacing string matches on imports with full paths. The repo has great amounts of detail and compiled output from a Windows and MacOS machine for comparison.

The resulting compiled code in question that seems to be resulting for this look like this on MacOS (works fine, non-buggy):

/***/ 71330:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {

function __ncc_wildcard$0 (arg) {
  if (arg === "mssql") return __webpack_require__(19427);
  else if (arg === "mysql") return __webpack_require__(75941);
  else if (arg === "mysql2") return __webpack_require__(17653);
  else if (arg === "oracle") return __webpack_require__(9051);
  else if (arg === "oracledb") return __webpack_require__(25310);
  else if (arg === "postgres") return __webpack_require__(64482);
  else if (arg === "redshift") return __webpack_require__(97332);
  else if (arg === "sqlite3") return __webpack_require__(85370);
}

but for some reason is transformed into the following in a Windows environment:

/***/ 71330:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {

function __ncc_wildcard$0 (arg) {
  if (arg === "C:/code/urbdyn/ncc-bug-1/node_modules/knex/lib/dialects/") return __webpack_require__(19427);
  else if (arg === "C:/code/urbdyn/ncc-bug-1/node_modules/knex/lib/dialects/") return __webpack_require__(75941);
  else if (arg === "C:/code/urbdyn/ncc-bug-1/node_modules/knex/lib/dialects/") return __webpack_require__(17653);
  else if (arg === "C:/code/urbdyn/ncc-bug-1/node_modules/knex/lib/dialects/") return __webpack_require__(9051);
  else if (arg === "C:/code/urbdyn/ncc-bug-1/node_modules/knex/lib/dialects/") return __webpack_require__(25310);
  else if (arg === "C:/code/urbdyn/ncc-bug-1/node_modules/knex/lib/dialects/") return __webpack_require__(64482);
  else if (arg === "C:/code/urbdyn/ncc-bug-1/node_modules/knex/lib/dialects/") return __webpack_require__(97332);
  else if (arg === "C:/code/urbdyn/ncc-bug-1/node_modules/knex/lib/dialects/") return __webpack_require__(85370);
}

As you can see, something very strange is occurring here which is resulting in a string comparison being replaced by the same directory path, in a hard coded manner.

I did do a bit of research on other issues in this repo and, after a bit more digging, that this seems to be a similar issue to #451.

Don't hesitate to let us know if you need any more information! Full environment details for the systems are given in the example repo.

Tagging @josh-josh-miller for visibility since he is also affected by this problem.

@d-513
Copy link

d-513 commented Nov 3, 2020

same issue here

@thiagoferolla
Copy link

Same here

@einsqing
Copy link

Same here

const newKnex = makeKnex(new Dialect(config));
^

TypeError: Dialect is not a constructor

@microCloudCode
Copy link

Same here

@springJia
Copy link

same there

@code-ape
Copy link
Author

code-ape commented Feb 7, 2021

This appears to have been resolved is definitely not resolved with ncc release 0.27.0. My particular use case now still does not work 😞 let me know if there's anything I can do to help with this!

PS - I had originally thought this was fixed as my regex work around code wasn't picking up any matches, but this is due to some minor renaming as __webpack_require__ has been changed to __nccwpck_require__ in the ncc output from 0.24 to 0.27. My regex work around still functions so this seems overall unchanged across versions.

@kibertoad
Copy link

@microCloudCode Can you try the 0.27.0 and report back if you still experience a problem?

@einsqing
Copy link

@microCloudCode Can you try the 0.27.0 and report back if you still experience a problem?

same issue on 0.27.0

@einsqing
Copy link

const knex = require('knex')({ client: require("knex/lib/dialects/sqlite3") });
This will work!

@yichi-yang
Copy link

yichi-yang commented Mar 22, 2022

This should have been fixed in this PR: vercel/webpack-asset-relocator-loader#153
(need to bump @vercel/webpack-asset-relocator-loader in this repo).

@styfle
Copy link
Member

styfle commented Apr 11, 2022

@styfle styfle closed this as completed Apr 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants