@atlaspack/node-resolver-core 3.5.5-canary.17 → 3.5.5-canary.170

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
@@ -71,6 +71,8 @@ function _featureFlags() {
71
71
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
72
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
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; }
74
+ // @ts-expect-error TS2305
75
+
74
76
  // Package.json fields. Must match package_json.rs.
75
77
  const MAIN = 1 << 0;
76
78
  const MODULE = 1 << 1;
@@ -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
  }
@@ -596,27 +594,33 @@ class NodeResolver {
596
594
  exports.default = NodeResolver;
597
595
  function environmentToExportsConditions(env, mode) {
598
596
  // These must match the values in package_json.rs.
599
-
597
+ const NODE = 1 << 3;
598
+ const BROWSER = 1 << 4;
599
+ const WORKER = 1 << 5;
600
+ const WORKLET = 1 << 6;
601
+ const ELECTRON = 1 << 7;
602
+ const DEVELOPMENT = 1 << 8;
603
+ const PRODUCTION = 1 << 9;
600
604
  let conditions = 0;
601
605
  if (env.isBrowser()) {
602
- conditions |= 1 << 4;
606
+ conditions |= BROWSER;
603
607
  }
604
- if (env.isWorker()) {
605
- conditions |= 1 << 5;
608
+ if (env.isWorker() || env.isTesseract()) {
609
+ conditions |= WORKER;
606
610
  }
607
611
  if (env.isWorklet()) {
608
- conditions |= 1 << 6;
612
+ conditions |= WORKLET;
609
613
  }
610
614
  if (env.isElectron()) {
611
- conditions |= 1 << 7;
615
+ conditions |= ELECTRON;
612
616
  }
613
617
  if (env.isNode()) {
614
- conditions |= 1 << 3;
618
+ conditions |= NODE;
615
619
  }
616
620
  if (mode === 'production') {
617
- conditions |= 1 << 9;
621
+ conditions |= PRODUCTION;
618
622
  } else if (mode === 'development') {
619
- conditions |= 1 << 8;
623
+ conditions |= DEVELOPMENT;
620
624
  }
621
625
  return conditions;
622
626
  }
@@ -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.17+a1773d2a6",
3
+ "version": "3.5.5-canary.170+c940954d2",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -9,23 +9,26 @@
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
+ "check-ts": "tsc --emitDeclarationOnly --rootDir src",
21
+ "build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
19
22
  },
20
23
  "files": [
21
24
  "lib"
22
25
  ],
23
26
  "dependencies": {
24
- "@atlaspack/diagnostic": "2.14.1-canary.85+a1773d2a6",
25
- "@atlaspack/feature-flags": "2.14.1-canary.85+a1773d2a6",
26
- "@atlaspack/fs": "2.14.5-canary.17+a1773d2a6",
27
- "@atlaspack/rust": "3.2.1-canary.17+a1773d2a6",
28
- "@atlaspack/utils": "2.14.5-canary.17+a1773d2a6",
27
+ "@atlaspack/diagnostic": "2.14.1-canary.238+c940954d2",
28
+ "@atlaspack/feature-flags": "2.14.1-canary.238+c940954d2",
29
+ "@atlaspack/fs": "2.14.5-canary.170+c940954d2",
30
+ "@atlaspack/rust": "3.2.1-canary.170+c940954d2",
31
+ "@atlaspack/utils": "2.14.5-canary.170+c940954d2",
29
32
  "@mischnic/json-sourcemap": "^0.1.0",
30
33
  "nullthrows": "^1.1.1",
31
34
  "semver": "^7.5.2"
@@ -58,5 +61,5 @@
58
61
  "./src/builtins.js": "./src/builtins.browser.js"
59
62
  },
60
63
  "type": "commonjs",
61
- "gitHead": "a1773d2a62d0ef7805ac7524621dcabcc1afe929"
64
+ "gitHead": "c940954d27d657c3c93cd328dfb394778da46eab"
62
65
  }