@atlaspack/node-resolver-core 3.5.5-canary.47 → 3.5.5-canary.471

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.
package/lib/Wrapper.js CHANGED
@@ -68,15 +68,17 @@ function _featureFlags() {
68
68
  };
69
69
  return data;
70
70
  }
71
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
72
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
73
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
71
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
72
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
73
+ // @ts-expect-error TS2305
74
+
74
75
  // Package.json fields. Must match package_json.rs.
75
76
  const MAIN = 1 << 0;
76
77
  const MODULE = 1 << 1;
77
78
  const SOURCE = 1 << 2;
78
79
  const BROWSER = 1 << 3;
79
80
  const TYPES = 1 << 6;
81
+ const MODULE_ES2019 = 1 << 7;
80
82
  class NodeResolver {
81
83
  constructor(options) {
82
84
  this.options = options;
@@ -116,7 +118,7 @@ class NodeResolver {
116
118
  conditions: environmentToExportsConditions(options.env, this.options.mode),
117
119
  packageExports: this.options.packageExports ?? false,
118
120
  moduleDirResolver: process.versions.pnp != null ? (module, from) => {
119
- // $FlowFixMe[prop-missing]
121
+ // @ts-expect-error TS2339
120
122
  let pnp = _module().default.findPnpApi(_path().default.dirname(from));
121
123
  return pnp.resolveToUnqualified(
122
124
  // append slash to force loading builtins from npm
@@ -137,16 +139,12 @@ class NodeResolver {
137
139
 
138
140
  // Async resolver is only supported in non-WASM environments, and does not support JS callbacks (e.g. FS, PnP).
139
141
  let canResolveAsync = !_rust().init && this.options.fs instanceof _fs().NodeFS && process.versions.pnp == null;
140
- let res = canResolveAsync ?
141
- // $FlowFixMe[incompatible-call] - parent is not null here.
142
- await resolver.resolveAsync(options) :
143
- // $FlowFixMe[incompatible-call] - parent is not null here.
144
- resolver.resolve(options);
142
+ let res = canResolveAsync ? await resolver.resolveAsync(options) : resolver.resolve(options);
145
143
 
146
144
  // Invalidate whenever the .pnp.js file changes.
147
145
  // TODO: only when we actually resolve a node_modules package?
148
146
  if (process.versions.pnp != null && options.parent && res.invalidateOnFileChange) {
149
- // $FlowFixMe[prop-missing]
147
+ // @ts-expect-error TS2339
150
148
  let pnp = _module().default.findPnpApi(_path().default.dirname(options.parent));
151
149
  res.invalidateOnFileChange.push(pnp.resolveToUnqualified('pnpapi', null));
152
150
  }
@@ -325,7 +323,6 @@ class NodeResolver {
325
323
  let potentialFiles = await (0, _utils().findAlternativeFiles)(this.options.fs, relative, dir, this.options.projectRoot, true, options.specifierType !== 'url'
326
324
  // extensions.length === 0,
327
325
  );
328
-
329
326
  return {
330
327
  message: (0, _diagnostic().md)`Cannot load file '${relative}' in '${(0, _utils().relativePath)(this.options.projectRoot, dir)}'.`,
331
328
  hints: potentialFiles.map(r => {
@@ -596,27 +593,33 @@ class NodeResolver {
596
593
  exports.default = NodeResolver;
597
594
  function environmentToExportsConditions(env, mode) {
598
595
  // These must match the values in package_json.rs.
599
-
596
+ const NODE = 1 << 3;
597
+ const BROWSER = 1 << 4;
598
+ const WORKER = 1 << 5;
599
+ const WORKLET = 1 << 6;
600
+ const ELECTRON = 1 << 7;
601
+ const DEVELOPMENT = 1 << 8;
602
+ const PRODUCTION = 1 << 9;
600
603
  let conditions = 0;
601
604
  if (env.isBrowser()) {
602
- conditions |= 1 << 4;
605
+ conditions |= BROWSER;
603
606
  }
604
- if (env.isWorker()) {
605
- conditions |= 1 << 5;
607
+ if (env.isWorker() || env.isTesseract()) {
608
+ conditions |= WORKER;
606
609
  }
607
610
  if (env.isWorklet()) {
608
- conditions |= 1 << 6;
611
+ conditions |= WORKLET;
609
612
  }
610
613
  if (env.isElectron()) {
611
- conditions |= 1 << 7;
614
+ conditions |= ELECTRON;
612
615
  }
613
616
  if (env.isNode()) {
614
- conditions |= 1 << 3;
617
+ conditions |= NODE;
615
618
  }
616
619
  if (mode === 'production') {
617
- conditions |= 1 << 9;
620
+ conditions |= PRODUCTION;
618
621
  } else if (mode === 'development') {
619
- conditions |= 1 << 8;
622
+ conditions |= DEVELOPMENT;
620
623
  }
621
624
  return conditions;
622
625
  }
@@ -630,6 +633,9 @@ function mainFieldsToEntries(mainFields) {
630
633
  case 'module':
631
634
  entries |= MODULE;
632
635
  break;
636
+ case 'module:es2019':
637
+ entries |= MODULE_ES2019;
638
+ break;
633
639
  case 'source':
634
640
  entries |= SOURCE;
635
641
  break;
@@ -6,9 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.empty = exports.default = void 0;
7
7
  const builtinModules = ['_http_agent', '_http_client', '_http_common', '_http_incoming', '_http_outgoing', '_http_server', '_stream_duplex', '_stream_passthrough', '_stream_readable', '_stream_transform', '_stream_wrap', '_stream_writable', '_tls_common', '_tls_wrap', 'assert', 'assert/strict', 'async_hooks', 'buffer', 'child_process', 'cluster', 'console', 'constants', 'crypto', 'dgram', 'diagnostics_channel', 'dns', 'dns/promises', 'domain', 'events', 'fs', 'fs/promises', 'http', 'http2', 'https', 'inspector', 'module', 'net', 'os', 'path', 'path/posix', 'path/win32', 'perf_hooks', 'process', 'punycode', 'querystring', 'readline', 'repl', 'stream', 'stream/consumers', 'stream/promises', 'stream/web', 'string_decoder', 'sys', 'timers', 'timers/promises', 'tls', 'trace_events', 'tty', 'url', 'util', 'util/types', 'v8', 'vm', 'worker_threads', 'zlib'];
8
8
  const empty = exports.empty = '/_empty.js';
9
- let builtins =
10
- // $FlowFixMe
11
- Object.create(null);
9
+ let builtins = Object.create(null);
12
10
 
13
11
  // use definite (current) list of Node builtins
14
12
  for (let key of builtinModules) {
package/lib/builtins.js CHANGED
@@ -19,13 +19,11 @@ function _nullthrows() {
19
19
  return data;
20
20
  }
21
21
  var _package = _interopRequireDefault(require("../package.json"));
22
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
- // $FlowFixMe this is untyped
22
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
24
23
  // flowlint-next-line untyped-import:off
24
+
25
25
  const empty = exports.empty = require.resolve('./_empty.js');
26
- let builtins =
27
- // $FlowFixMe
28
- Object.create(null);
26
+ let builtins = Object.create(null);
29
27
 
30
28
  // use definite (current) list of Node builtins
31
29
  for (let key of _module().builtinModules) {
@@ -60,9 +58,11 @@ let polyfills = {
60
58
  zlib: 'browserify-zlib'
61
59
  };
62
60
  for (let k in polyfills) {
61
+ // @ts-expect-error TS7053
63
62
  let polyfill = polyfills[k];
64
63
  builtins[k] = {
65
64
  name: polyfill + (_module().builtinModules.includes(polyfill) ? '/' : ''),
65
+ // @ts-expect-error TS7053
66
66
  range: (0, _nullthrows().default)(_package.default.devDependencies[polyfill])
67
67
  };
68
68
  }
package/lib/index.js CHANGED
@@ -24,5 +24,7 @@ function _rust() {
24
24
  return data;
25
25
  }
26
26
  var _Wrapper = _interopRequireDefault(require("./Wrapper"));
27
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
- const ResolverBase = exports.ResolverBase = _rust().Resolver;
27
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
28
+ const ResolverBase = exports.ResolverBase = _rust().Resolver;
29
+
30
+ // @ts-expect-error TS2305
@@ -0,0 +1,34 @@
1
+ import type { FilePath, SpecifierType, SemverRange, Environment, SourceLocation, BuildMode, ResolveResult, PluginLogger, FileSystem, PackageManager } from '@atlaspack/types';
2
+ import type { Diagnostic } from '@atlaspack/diagnostic';
3
+ type Options = {
4
+ fs: FileSystem;
5
+ projectRoot: FilePath;
6
+ packageManager?: PackageManager;
7
+ logger?: PluginLogger;
8
+ shouldAutoInstall?: boolean;
9
+ mode: BuildMode;
10
+ mainFields?: Array<string>;
11
+ extensions?: Array<string>;
12
+ packageExports?: boolean;
13
+ };
14
+ type ResolveOptions = {
15
+ filename: FilePath;
16
+ parent: FilePath | null | undefined;
17
+ specifierType: SpecifierType;
18
+ range?: SemverRange | null | undefined;
19
+ env: Environment;
20
+ sourcePath?: FilePath | null | undefined;
21
+ loc?: SourceLocation | null | undefined;
22
+ packageConditions?: Array<string> | null | undefined;
23
+ };
24
+ export default class NodeResolver {
25
+ resolversByEnv: Map<string, any>;
26
+ options: Options;
27
+ constructor(options: Options);
28
+ resolve(options: ResolveOptions): Promise<ResolveResult | null | undefined>;
29
+ resolveBuiltin(name: string, options: ResolveOptions): Promise<ResolveResult | null | undefined>;
30
+ shouldIncludeNodeModule({ includeNodeModules }: Environment, name: string): boolean | null | undefined;
31
+ handleError(error: any, options: ResolveOptions): Promise<Diagnostic | Array<Diagnostic> | null | undefined>;
32
+ checkExcludedDependency(sourceFile: FilePath, name: string, options: ResolveOptions): Promise<Diagnostic | null | undefined>;
33
+ }
34
+ export {};
@@ -0,0 +1,8 @@
1
+ export declare const empty: string;
2
+ declare let builtins: {
3
+ [key: string]: {
4
+ name: string;
5
+ range: string | null | undefined;
6
+ };
7
+ };
8
+ export default builtins;
@@ -0,0 +1,8 @@
1
+ export declare const empty: string;
2
+ declare let builtins: {
3
+ [key: string]: {
4
+ name: string;
5
+ range: string | null | undefined;
6
+ };
7
+ };
8
+ export default builtins;
@@ -0,0 +1,4 @@
1
+ import { Resolver } from '@atlaspack/rust';
2
+ export declare const ResolverBase: typeof Resolver;
3
+ export { default } from './Wrapper';
4
+ export { init } from '@atlaspack/rust';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/node-resolver-core",
3
- "version": "3.5.5-canary.47+29c2f106d",
3
+ "version": "3.5.5-canary.471+9fd756210",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -9,23 +9,25 @@
9
9
  "type": "git",
10
10
  "url": "https://github.com/atlassian-labs/atlaspack.git"
11
11
  },
12
- "main": "lib/index.js",
13
- "source": "src/index.js",
12
+ "main": "./lib/index.js",
13
+ "source": "./src/index.ts",
14
+ "types": "./lib/types/index.d.ts",
14
15
  "engines": {
15
16
  "node": ">= 16.0.0"
16
17
  },
17
18
  "scripts": {
18
- "test": "mocha test"
19
+ "test": "mocha test",
20
+ "build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
19
21
  },
20
22
  "files": [
21
23
  "lib"
22
24
  ],
23
25
  "dependencies": {
24
- "@atlaspack/diagnostic": "2.14.1-canary.115+29c2f106d",
25
- "@atlaspack/feature-flags": "2.14.1-canary.115+29c2f106d",
26
- "@atlaspack/fs": "2.14.5-canary.47+29c2f106d",
27
- "@atlaspack/rust": "3.2.1-canary.47+29c2f106d",
28
- "@atlaspack/utils": "2.14.5-canary.47+29c2f106d",
26
+ "@atlaspack/diagnostic": "2.14.1-canary.539+9fd756210",
27
+ "@atlaspack/feature-flags": "2.14.1-canary.539+9fd756210",
28
+ "@atlaspack/fs": "2.14.5-canary.471+9fd756210",
29
+ "@atlaspack/rust": "3.2.1-canary.471+9fd756210",
30
+ "@atlaspack/utils": "2.14.5-canary.471+9fd756210",
29
31
  "@mischnic/json-sourcemap": "^0.1.0",
30
32
  "nullthrows": "^1.1.1",
31
33
  "semver": "^7.5.2"
@@ -37,7 +39,7 @@
37
39
  "console-browserify": "^1.2.0",
38
40
  "constants-browserify": "^1.0.0",
39
41
  "crypto-browserify": "^3.12.0",
40
- "domain-browser": "^3.5.0",
42
+ "domain-browser": "^5.7.0",
41
43
  "events": "^3.1.0",
42
44
  "https-browserify": "^1.0.0",
43
45
  "os-browserify": "^0.3.0",
@@ -58,5 +60,5 @@
58
60
  "./src/builtins.js": "./src/builtins.browser.js"
59
61
  },
60
62
  "type": "commonjs",
61
- "gitHead": "29c2f106de9679adfb5afa04e1910471dc65a427"
62
- }
63
+ "gitHead": "9fd756210b9b1f6db3897fbcf0a6dd3bcfd2c1a3"
64
+ }