@prosopo/procaptcha-bundle 4.4.4 → 4.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,8 +12,31 @@
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
14
  const getWebpackConfig = require("@prosopo/config/webpack/webpack.config");
15
+ const fs = require("node:fs");
15
16
  const path = require("node:path");
16
- const fg = require("fast-glob");
17
+
18
+ // Walk up for the install rather than assuming one two levels above this
19
+ // package. That assumption holds only when this repo is the workspace root; as
20
+ // a submodule of captcha-private the hoisted node_modules is a level higher
21
+ // again, so both aliases below pointed at a directory that does not exist and
22
+ // every @polkadot/util copy failed to resolve them.
23
+ const packageDir = (name) => {
24
+ let dir = __dirname;
25
+ for (;;) {
26
+ const candidate = path.join(dir, "node_modules", name);
27
+ if (fs.existsSync(candidate)) {
28
+ return candidate;
29
+ }
30
+ const parent = path.dirname(dir);
31
+ if (parent === dir) {
32
+ throw new Error(
33
+ `Cannot find ${name} in any node_modules above ${__dirname}`,
34
+ );
35
+ }
36
+ dir = parent;
37
+ }
38
+ };
39
+
17
40
  const args = process.argv.slice(2);
18
41
  const mode =
19
42
  args.indexOf("--mode") > -1
@@ -21,28 +44,23 @@ const mode =
21
44
  : "development";
22
45
  const webpackConfig = getWebpackConfig(mode);
23
46
 
24
- const rootDir = path.resolve(__dirname, "../..");
25
- console.log("Looking in", rootDir);
26
-
27
- const nodeModulePaths = fg.sync("**/node_modules", {
28
- onlyDirectories: true,
29
- cwd: rootDir,
30
- });
31
-
32
- console.log(nodeModulePaths);
33
-
34
47
  const bundleWebpackConfig = {
35
48
  ...webpackConfig,
36
49
  resolve: {
37
50
  ...webpackConfig.resolve,
38
- modules: nodeModulePaths,
51
+ // The shared config pins resolve.modules to this package's own
52
+ // node_modules, which switches off the upward walk, so everything
53
+ // hoisted to the workspace root goes missing. This used to be papered
54
+ // over by listing every node_modules directory in the repo, which then
55
+ // made each nested install a global resolution root -- a transitive
56
+ // copy such as @noble/curves' own @noble/hashes could satisfy a bare
57
+ // `@noble/hashes/sha256` and fail on its exports map. The bare string
58
+ // is webpack's default: walk up from the importer, exactly as node
59
+ // does. The two aliases below are the only deliberate deviation.
60
+ modules: ["node_modules"],
39
61
  alias: {
40
- "@polkadot/x-textdecoder": path.resolve(
41
- "../../node_modules/@polkadot/x-textdecoder",
42
- ),
43
- "@polkadot/x-textencoder": path.resolve(
44
- "../../node_modules/@polkadot/x-textencoder",
45
- ),
62
+ "@polkadot/x-textdecoder": packageDir("@polkadot/x-textdecoder"),
63
+ "@polkadot/x-textencoder": packageDir("@polkadot/x-textencoder"),
46
64
  },
47
65
  },
48
66
  externals: {
@@ -51,5 +69,5 @@ const bundleWebpackConfig = {
51
69
  "node:util": "commonjs util",
52
70
  },
53
71
  };
54
- console.log(bundleWebpackConfig);
72
+
55
73
  module.exports = bundleWebpackConfig;