@atlaspack/node-resolver-core 3.5.5-canary.24 → 3.5.5-canary.241

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
@@ -61,22 +61,18 @@ function _module() {
61
61
  };
62
62
  return data;
63
63
  }
64
- function _featureFlags() {
65
- const data = require("@atlaspack/feature-flags");
66
- _featureFlags = function () {
67
- return data;
68
- };
69
- return data;
70
- }
71
64
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
72
65
  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
66
  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; }
67
+ // @ts-expect-error TS2305
68
+
74
69
  // Package.json fields. Must match package_json.rs.
75
70
  const MAIN = 1 << 0;
76
71
  const MODULE = 1 << 1;
77
72
  const SOURCE = 1 << 2;
78
73
  const BROWSER = 1 << 3;
79
74
  const TYPES = 1 << 6;
75
+ const MODULE_ES2019 = 1 << 7;
80
76
  class NodeResolver {
81
77
  constructor(options) {
82
78
  this.options = options;
@@ -116,13 +112,12 @@ class NodeResolver {
116
112
  conditions: environmentToExportsConditions(options.env, this.options.mode),
117
113
  packageExports: this.options.packageExports ?? false,
118
114
  moduleDirResolver: process.versions.pnp != null ? (module, from) => {
119
- // $FlowFixMe[prop-missing]
115
+ // @ts-expect-error TS2339
120
116
  let pnp = _module().default.findPnpApi(_path().default.dirname(from));
121
117
  return pnp.resolveToUnqualified(
122
118
  // append slash to force loading builtins from npm
123
119
  module + '/', from);
124
- } : undefined,
125
- reduceStringCreation: (0, _featureFlags().getFeatureFlag)('reduceResolverStringCreation')
120
+ } : undefined
126
121
  });
127
122
  this.resolversByEnv.set(options.env.id, resolver);
128
123
  }
@@ -137,16 +132,12 @@ class NodeResolver {
137
132
 
138
133
  // Async resolver is only supported in non-WASM environments, and does not support JS callbacks (e.g. FS, PnP).
139
134
  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);
135
+ let res = canResolveAsync ? await resolver.resolveAsync(options) : resolver.resolve(options);
145
136
 
146
137
  // Invalidate whenever the .pnp.js file changes.
147
138
  // TODO: only when we actually resolve a node_modules package?
148
139
  if (process.versions.pnp != null && options.parent && res.invalidateOnFileChange) {
149
- // $FlowFixMe[prop-missing]
140
+ // @ts-expect-error TS2339
150
141
  let pnp = _module().default.findPnpApi(_path().default.dirname(options.parent));
151
142
  res.invalidateOnFileChange.push(pnp.resolveToUnqualified('pnpapi', null));
152
143
  }
@@ -596,27 +587,33 @@ class NodeResolver {
596
587
  exports.default = NodeResolver;
597
588
  function environmentToExportsConditions(env, mode) {
598
589
  // These must match the values in package_json.rs.
599
-
590
+ const NODE = 1 << 3;
591
+ const BROWSER = 1 << 4;
592
+ const WORKER = 1 << 5;
593
+ const WORKLET = 1 << 6;
594
+ const ELECTRON = 1 << 7;
595
+ const DEVELOPMENT = 1 << 8;
596
+ const PRODUCTION = 1 << 9;
600
597
  let conditions = 0;
601
598
  if (env.isBrowser()) {
602
- conditions |= 1 << 4;
599
+ conditions |= BROWSER;
603
600
  }
604
- if (env.isWorker()) {
605
- conditions |= 1 << 5;
601
+ if (env.isWorker() || env.isTesseract()) {
602
+ conditions |= WORKER;
606
603
  }
607
604
  if (env.isWorklet()) {
608
- conditions |= 1 << 6;
605
+ conditions |= WORKLET;
609
606
  }
610
607
  if (env.isElectron()) {
611
- conditions |= 1 << 7;
608
+ conditions |= ELECTRON;
612
609
  }
613
610
  if (env.isNode()) {
614
- conditions |= 1 << 3;
611
+ conditions |= NODE;
615
612
  }
616
613
  if (mode === 'production') {
617
- conditions |= 1 << 9;
614
+ conditions |= PRODUCTION;
618
615
  } else if (mode === 'development') {
619
- conditions |= 1 << 8;
616
+ conditions |= DEVELOPMENT;
620
617
  }
621
618
  return conditions;
622
619
  }
@@ -630,6 +627,9 @@ function mainFieldsToEntries(mainFields) {
630
627
  case 'module':
631
628
  entries |= MODULE;
632
629
  break;
630
+ case 'module:es2019':
631
+ entries |= MODULE_ES2019;
632
+ break;
633
633
  case 'source':
634
634
  entries |= SOURCE;
635
635
  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
@@ -20,12 +20,10 @@ function _nullthrows() {
20
20
  }
21
21
  var _package = _interopRequireDefault(require("../package.json"));
22
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
- // $FlowFixMe this is untyped
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
@@ -25,4 +25,6 @@ function _rust() {
25
25
  }
26
26
  var _Wrapper = _interopRequireDefault(require("./Wrapper"));
27
27
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
- const ResolverBase = exports.ResolverBase = _rust().Resolver;
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.24+9b814a847",
3
+ "version": "3.5.5-canary.241+816fbf634",
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.92+9b814a847",
25
- "@atlaspack/feature-flags": "2.14.1-canary.92+9b814a847",
26
- "@atlaspack/fs": "2.14.5-canary.24+9b814a847",
27
- "@atlaspack/rust": "3.2.1-canary.24+9b814a847",
28
- "@atlaspack/utils": "2.14.5-canary.24+9b814a847",
26
+ "@atlaspack/diagnostic": "2.14.1-canary.309+816fbf634",
27
+ "@atlaspack/feature-flags": "2.14.1-canary.309+816fbf634",
28
+ "@atlaspack/fs": "2.14.5-canary.241+816fbf634",
29
+ "@atlaspack/rust": "3.2.1-canary.241+816fbf634",
30
+ "@atlaspack/utils": "2.14.5-canary.241+816fbf634",
29
31
  "@mischnic/json-sourcemap": "^0.1.0",
30
32
  "nullthrows": "^1.1.1",
31
33
  "semver": "^7.5.2"
@@ -58,5 +60,5 @@
58
60
  "./src/builtins.js": "./src/builtins.browser.js"
59
61
  },
60
62
  "type": "commonjs",
61
- "gitHead": "9b814a847d7f5bd71f9e84eb498598ef90c7bd3a"
62
- }
63
+ "gitHead": "816fbf634125215c3b4f2d79c0cd4a976648f1dc"
64
+ }