@atlaspack/node-resolver-core 3.5.5-canary.36 → 3.5.5-canary.360
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 +24 -16
- package/lib/builtins.browser.js +1 -3
- package/lib/builtins.js +4 -4
- package/lib/index.js +3 -1
- package/lib/types/Wrapper.d.ts +34 -0
- package/lib/types/builtins.browser.d.ts +8 -0
- package/lib/types/builtins.d.ts +8 -0
- package/lib/types/index.d.ts +4 -0
- package/package.json +13 -11
package/lib/Wrapper.js
CHANGED
|
@@ -71,12 +71,15 @@ 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;
|
|
77
79
|
const SOURCE = 1 << 2;
|
|
78
80
|
const BROWSER = 1 << 3;
|
|
79
81
|
const TYPES = 1 << 6;
|
|
82
|
+
const MODULE_ES2019 = 1 << 7;
|
|
80
83
|
class NodeResolver {
|
|
81
84
|
constructor(options) {
|
|
82
85
|
this.options = options;
|
|
@@ -116,7 +119,7 @@ class NodeResolver {
|
|
|
116
119
|
conditions: environmentToExportsConditions(options.env, this.options.mode),
|
|
117
120
|
packageExports: this.options.packageExports ?? false,
|
|
118
121
|
moduleDirResolver: process.versions.pnp != null ? (module, from) => {
|
|
119
|
-
//
|
|
122
|
+
// @ts-expect-error TS2339
|
|
120
123
|
let pnp = _module().default.findPnpApi(_path().default.dirname(from));
|
|
121
124
|
return pnp.resolveToUnqualified(
|
|
122
125
|
// append slash to force loading builtins from npm
|
|
@@ -137,16 +140,12 @@ class NodeResolver {
|
|
|
137
140
|
|
|
138
141
|
// Async resolver is only supported in non-WASM environments, and does not support JS callbacks (e.g. FS, PnP).
|
|
139
142
|
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);
|
|
143
|
+
let res = canResolveAsync ? await resolver.resolveAsync(options) : resolver.resolve(options);
|
|
145
144
|
|
|
146
145
|
// Invalidate whenever the .pnp.js file changes.
|
|
147
146
|
// TODO: only when we actually resolve a node_modules package?
|
|
148
147
|
if (process.versions.pnp != null && options.parent && res.invalidateOnFileChange) {
|
|
149
|
-
//
|
|
148
|
+
// @ts-expect-error TS2339
|
|
150
149
|
let pnp = _module().default.findPnpApi(_path().default.dirname(options.parent));
|
|
151
150
|
res.invalidateOnFileChange.push(pnp.resolveToUnqualified('pnpapi', null));
|
|
152
151
|
}
|
|
@@ -596,27 +595,33 @@ class NodeResolver {
|
|
|
596
595
|
exports.default = NodeResolver;
|
|
597
596
|
function environmentToExportsConditions(env, mode) {
|
|
598
597
|
// These must match the values in package_json.rs.
|
|
599
|
-
|
|
598
|
+
const NODE = 1 << 3;
|
|
599
|
+
const BROWSER = 1 << 4;
|
|
600
|
+
const WORKER = 1 << 5;
|
|
601
|
+
const WORKLET = 1 << 6;
|
|
602
|
+
const ELECTRON = 1 << 7;
|
|
603
|
+
const DEVELOPMENT = 1 << 8;
|
|
604
|
+
const PRODUCTION = 1 << 9;
|
|
600
605
|
let conditions = 0;
|
|
601
606
|
if (env.isBrowser()) {
|
|
602
|
-
conditions |=
|
|
607
|
+
conditions |= BROWSER;
|
|
603
608
|
}
|
|
604
|
-
if (env.isWorker()) {
|
|
605
|
-
conditions |=
|
|
609
|
+
if (env.isWorker() || env.isTesseract()) {
|
|
610
|
+
conditions |= WORKER;
|
|
606
611
|
}
|
|
607
612
|
if (env.isWorklet()) {
|
|
608
|
-
conditions |=
|
|
613
|
+
conditions |= WORKLET;
|
|
609
614
|
}
|
|
610
615
|
if (env.isElectron()) {
|
|
611
|
-
conditions |=
|
|
616
|
+
conditions |= ELECTRON;
|
|
612
617
|
}
|
|
613
618
|
if (env.isNode()) {
|
|
614
|
-
conditions |=
|
|
619
|
+
conditions |= NODE;
|
|
615
620
|
}
|
|
616
621
|
if (mode === 'production') {
|
|
617
|
-
conditions |=
|
|
622
|
+
conditions |= PRODUCTION;
|
|
618
623
|
} else if (mode === 'development') {
|
|
619
|
-
conditions |=
|
|
624
|
+
conditions |= DEVELOPMENT;
|
|
620
625
|
}
|
|
621
626
|
return conditions;
|
|
622
627
|
}
|
|
@@ -630,6 +635,9 @@ function mainFieldsToEntries(mainFields) {
|
|
|
630
635
|
case 'module':
|
|
631
636
|
entries |= MODULE;
|
|
632
637
|
break;
|
|
638
|
+
case 'module:es2019':
|
|
639
|
+
entries |= MODULE_ES2019;
|
|
640
|
+
break;
|
|
633
641
|
case 'source':
|
|
634
642
|
entries |= SOURCE;
|
|
635
643
|
break;
|
package/lib/builtins.browser.js
CHANGED
|
@@ -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 {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/node-resolver-core",
|
|
3
|
-
"version": "3.5.5-canary.
|
|
3
|
+
"version": "3.5.5-canary.360+fc3adc098",
|
|
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.
|
|
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.
|
|
25
|
-
"@atlaspack/feature-flags": "2.14.1-canary.
|
|
26
|
-
"@atlaspack/fs": "2.14.5-canary.
|
|
27
|
-
"@atlaspack/rust": "3.2.1-canary.
|
|
28
|
-
"@atlaspack/utils": "2.14.5-canary.
|
|
26
|
+
"@atlaspack/diagnostic": "2.14.1-canary.428+fc3adc098",
|
|
27
|
+
"@atlaspack/feature-flags": "2.14.1-canary.428+fc3adc098",
|
|
28
|
+
"@atlaspack/fs": "2.14.5-canary.360+fc3adc098",
|
|
29
|
+
"@atlaspack/rust": "3.2.1-canary.360+fc3adc098",
|
|
30
|
+
"@atlaspack/utils": "2.14.5-canary.360+fc3adc098",
|
|
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": "
|
|
62
|
-
}
|
|
63
|
+
"gitHead": "fc3adc098f583e40d6d7687412cac6dde7cbb3f3"
|
|
64
|
+
}
|