@atlaspack/core 2.13.2-dev.3682 → 2.14.0
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/CHANGELOG.md +61 -0
- package/package.json +20 -20
- package/src/Atlaspack.js +3 -2
- package/src/atlaspack-v3/AtlaspackV3.js +24 -8
- package/src/loadAtlaspackPlugin.js +26 -71
- package/src/projectPath.js +14 -1
- package/src/requests/WriteBundlesRequest.js +31 -22
- package/LICENSE +0 -201
- package/lib/AssetGraph.js +0 -521
- package/lib/Atlaspack.js +0 -676
- package/lib/AtlaspackConfig.js +0 -298
- package/lib/AtlaspackConfig.schema.js +0 -103
- package/lib/BundleGraph.js +0 -1527
- package/lib/CommittedAsset.js +0 -155
- package/lib/Dependency.js +0 -136
- package/lib/Environment.js +0 -144
- package/lib/IdentifierRegistry.js +0 -36
- package/lib/InternalConfig.js +0 -56
- package/lib/PackagerRunner.js +0 -525
- package/lib/ReporterRunner.js +0 -151
- package/lib/RequestTracker.js +0 -1178
- package/lib/SymbolPropagation.js +0 -618
- package/lib/TargetDescriptor.schema.js +0 -118
- package/lib/Transformation.js +0 -522
- package/lib/UncommittedAsset.js +0 -348
- package/lib/Validation.js +0 -203
- package/lib/applyRuntimes.js +0 -355
- package/lib/assetUtils.js +0 -205
- package/lib/atlaspack-v3/AtlaspackV3.js +0 -57
- package/lib/atlaspack-v3/NapiWorkerPool.js +0 -71
- package/lib/atlaspack-v3/fs.js +0 -39
- package/lib/atlaspack-v3/index.js +0 -26
- package/lib/atlaspack-v3/jsCallable.js +0 -20
- package/lib/atlaspack-v3/worker/compat/asset-symbols.js +0 -197
- package/lib/atlaspack-v3/worker/compat/bitflags.js +0 -84
- package/lib/atlaspack-v3/worker/compat/dependency.js +0 -44
- package/lib/atlaspack-v3/worker/compat/environment.js +0 -57
- package/lib/atlaspack-v3/worker/compat/index.js +0 -104
- package/lib/atlaspack-v3/worker/compat/mutable-asset.js +0 -164
- package/lib/atlaspack-v3/worker/compat/plugin-config.js +0 -78
- package/lib/atlaspack-v3/worker/compat/plugin-logger.js +0 -29
- package/lib/atlaspack-v3/worker/compat/plugin-options.js +0 -113
- package/lib/atlaspack-v3/worker/compat/plugin-tracer.js +0 -12
- package/lib/atlaspack-v3/worker/compat/target.js +0 -17
- package/lib/atlaspack-v3/worker/index.js +0 -3
- package/lib/atlaspack-v3/worker/worker.js +0 -280
- package/lib/constants.js +0 -21
- package/lib/dumpGraphToGraphViz.js +0 -206
- package/lib/index.js +0 -70
- package/lib/loadAtlaspackPlugin.js +0 -136
- package/lib/loadDotEnv.js +0 -54
- package/lib/projectPath.js +0 -94
- package/lib/public/Asset.js +0 -259
- package/lib/public/Bundle.js +0 -236
- package/lib/public/BundleGraph.js +0 -279
- package/lib/public/BundleGroup.js +0 -50
- package/lib/public/Config.js +0 -202
- package/lib/public/Dependency.js +0 -131
- package/lib/public/Environment.js +0 -247
- package/lib/public/MutableBundleGraph.js +0 -204
- package/lib/public/PluginOptions.js +0 -71
- package/lib/public/Symbols.js +0 -247
- package/lib/public/Target.js +0 -64
- package/lib/registerCoreWithSerializer.js +0 -51
- package/lib/requests/AssetGraphRequest.js +0 -432
- package/lib/requests/AssetGraphRequestRust.js +0 -220
- package/lib/requests/AssetRequest.js +0 -132
- package/lib/requests/AtlaspackBuildRequest.js +0 -79
- package/lib/requests/AtlaspackConfigRequest.js +0 -479
- package/lib/requests/BundleGraphRequest.js +0 -485
- package/lib/requests/ConfigRequest.js +0 -203
- package/lib/requests/DevDepRequest.js +0 -193
- package/lib/requests/EntryRequest.js +0 -295
- package/lib/requests/PackageRequest.js +0 -88
- package/lib/requests/PathRequest.js +0 -357
- package/lib/requests/TargetRequest.js +0 -1179
- package/lib/requests/ValidationRequest.js +0 -66
- package/lib/requests/WriteBundleRequest.js +0 -252
- package/lib/requests/WriteBundlesRequest.js +0 -153
- package/lib/requests/asset-graph-diff.js +0 -128
- package/lib/requests/asset-graph-dot.js +0 -131
- package/lib/resolveOptions.js +0 -265
- package/lib/serializerCore.browser.js +0 -29
- package/lib/summarizeRequest.js +0 -55
- package/lib/types.js +0 -35
- package/lib/utils.js +0 -160
- package/lib/worker.js +0 -184
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createDevDependency = createDevDependency;
|
|
7
|
-
exports.getDevDepRequests = getDevDepRequests;
|
|
8
|
-
exports.getWorkerDevDepRequests = getWorkerDevDepRequests;
|
|
9
|
-
exports.invalidateDevDeps = invalidateDevDeps;
|
|
10
|
-
exports.resolveDevDepRequestRef = resolveDevDepRequestRef;
|
|
11
|
-
exports.runDevDepRequest = runDevDepRequest;
|
|
12
|
-
function _buildCache() {
|
|
13
|
-
const data = require("@atlaspack/build-cache");
|
|
14
|
-
_buildCache = function () {
|
|
15
|
-
return data;
|
|
16
|
-
};
|
|
17
|
-
return data;
|
|
18
|
-
}
|
|
19
|
-
function _nullthrows() {
|
|
20
|
-
const data = _interopRequireDefault(require("nullthrows"));
|
|
21
|
-
_nullthrows = function () {
|
|
22
|
-
return data;
|
|
23
|
-
};
|
|
24
|
-
return data;
|
|
25
|
-
}
|
|
26
|
-
var _assetUtils = require("../assetUtils");
|
|
27
|
-
var _utils = require("../utils");
|
|
28
|
-
var _projectPath = require("../projectPath");
|
|
29
|
-
var _RequestTracker = require("../RequestTracker");
|
|
30
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
-
// A cache of dev dep requests keyed by invalidations.
|
|
32
|
-
// If the package manager returns the same invalidation object, then
|
|
33
|
-
// we can reuse the dev dep request rather than recomputing the project
|
|
34
|
-
// paths and hashes.
|
|
35
|
-
const devDepRequestCache = new WeakMap();
|
|
36
|
-
async function createDevDependency(opts, requestDevDeps, options) {
|
|
37
|
-
let {
|
|
38
|
-
specifier,
|
|
39
|
-
resolveFrom,
|
|
40
|
-
additionalInvalidations
|
|
41
|
-
} = opts;
|
|
42
|
-
let key = `${specifier}:${(0, _projectPath.fromProjectPathRelative)(resolveFrom)}`;
|
|
43
|
-
|
|
44
|
-
// If the request sent us a hash, we know the dev dep and all of its dependencies didn't change.
|
|
45
|
-
// Reuse the same hash in the response. No need to send back invalidations as the request won't
|
|
46
|
-
// be re-run anyway.
|
|
47
|
-
let hash = requestDevDeps.get(key);
|
|
48
|
-
if (hash != null) {
|
|
49
|
-
return {
|
|
50
|
-
type: 'ref',
|
|
51
|
-
specifier,
|
|
52
|
-
resolveFrom,
|
|
53
|
-
hash
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
let resolveFromAbsolute = (0, _projectPath.fromProjectPath)(options.projectRoot, resolveFrom);
|
|
57
|
-
|
|
58
|
-
// Ensure that the package manager has an entry for this resolution.
|
|
59
|
-
try {
|
|
60
|
-
await options.packageManager.resolve(specifier, resolveFromAbsolute);
|
|
61
|
-
} catch (err) {
|
|
62
|
-
// ignore
|
|
63
|
-
}
|
|
64
|
-
let invalidations = options.packageManager.getInvalidations(specifier, resolveFromAbsolute);
|
|
65
|
-
let cached = devDepRequestCache.get(invalidations);
|
|
66
|
-
if (cached != null) {
|
|
67
|
-
return cached;
|
|
68
|
-
}
|
|
69
|
-
let invalidateOnFileChangeProject = [...invalidations.invalidateOnFileChange].map(f => (0, _projectPath.toProjectPath)(options.projectRoot, f));
|
|
70
|
-
|
|
71
|
-
// It is possible for a transformer to have multiple different hashes due to
|
|
72
|
-
// different dependencies (e.g. conditional requires) so we must always
|
|
73
|
-
// recompute the hash and compare rather than only sending a transformer
|
|
74
|
-
// dev dependency once.
|
|
75
|
-
hash = await (0, _assetUtils.getInvalidationHash)(invalidateOnFileChangeProject.map(f => ({
|
|
76
|
-
type: 'file',
|
|
77
|
-
filePath: f
|
|
78
|
-
})), options);
|
|
79
|
-
let devDepRequest = {
|
|
80
|
-
specifier,
|
|
81
|
-
resolveFrom,
|
|
82
|
-
hash,
|
|
83
|
-
invalidateOnFileCreate: invalidations.invalidateOnFileCreate.map(i => (0, _utils.invalidateOnFileCreateToInternal)(options.projectRoot, i)),
|
|
84
|
-
invalidateOnFileChange: new Set(invalidateOnFileChangeProject),
|
|
85
|
-
invalidateOnStartup: invalidations.invalidateOnStartup,
|
|
86
|
-
additionalInvalidations
|
|
87
|
-
};
|
|
88
|
-
devDepRequestCache.set(invalidations, devDepRequest);
|
|
89
|
-
return devDepRequest;
|
|
90
|
-
}
|
|
91
|
-
async function getDevDepRequests(api) {
|
|
92
|
-
let previousDevDepRequests = new Map(await Promise.all(api.getSubRequests().filter(req => req.requestType === _RequestTracker.requestTypes.dev_dep_request).map(async req => [req.id, (0, _nullthrows().default)(await api.getRequestResult(req.id))])));
|
|
93
|
-
return {
|
|
94
|
-
devDeps: new Map([...previousDevDepRequests.entries()].filter(([id]) => api.canSkipSubrequest(id)).map(([, req]) => [`${req.specifier}:${(0, _projectPath.fromProjectPathRelative)(req.resolveFrom)}`, req.hash])),
|
|
95
|
-
invalidDevDeps: await Promise.all([...previousDevDepRequests.entries()].filter(([id]) => !api.canSkipSubrequest(id)).flatMap(([, req]) => {
|
|
96
|
-
return [{
|
|
97
|
-
specifier: req.specifier,
|
|
98
|
-
resolveFrom: req.resolveFrom
|
|
99
|
-
}, ...(req.additionalInvalidations ?? []).map(i => ({
|
|
100
|
-
specifier: i.specifier,
|
|
101
|
-
resolveFrom: i.resolveFrom
|
|
102
|
-
}))];
|
|
103
|
-
}))
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Tracks dev deps that have been invalidated during this build
|
|
108
|
-
// so we don't invalidate the require cache more than once.
|
|
109
|
-
const invalidatedDevDeps = (0, _buildCache().createBuildCache)();
|
|
110
|
-
function invalidateDevDeps(invalidDevDeps, options, config) {
|
|
111
|
-
for (let {
|
|
112
|
-
specifier,
|
|
113
|
-
resolveFrom
|
|
114
|
-
} of invalidDevDeps) {
|
|
115
|
-
let key = `${specifier}:${(0, _projectPath.fromProjectPathRelative)(resolveFrom)}`;
|
|
116
|
-
if (!invalidatedDevDeps.has(key)) {
|
|
117
|
-
config.invalidatePlugin(specifier);
|
|
118
|
-
options.packageManager.invalidate(specifier, (0, _projectPath.fromProjectPath)(options.projectRoot, resolveFrom));
|
|
119
|
-
invalidatedDevDeps.set(key, true);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
const devDepRequests = (0, _buildCache().createBuildCache)();
|
|
124
|
-
function resolveDevDepRequestRef(devDepRequestRef) {
|
|
125
|
-
const devDepRequest = devDepRequestRef.type === 'ref' ? devDepRequests.get(devDepRequestRef.hash) : devDepRequestRef;
|
|
126
|
-
if (devDepRequest == null) {
|
|
127
|
-
throw new Error(`Worker send back a reference to a missing dev dep request.
|
|
128
|
-
|
|
129
|
-
This might happen due to internal in-memory build caches not being cleared
|
|
130
|
-
between builds or due a race condition.
|
|
131
|
-
${process.env.NODE_ENV === 'test' ? `If this is a unit test, call atlaspack.clearBuildCaches() between tests` : ''}
|
|
132
|
-
|
|
133
|
-
This is a bug in Atlaspack.`);
|
|
134
|
-
}
|
|
135
|
-
if (devDepRequestRef.type !== 'ref') {
|
|
136
|
-
devDepRequests.set(devDepRequest.hash, devDepRequest);
|
|
137
|
-
}
|
|
138
|
-
return devDepRequest;
|
|
139
|
-
}
|
|
140
|
-
async function runDevDepRequest(api, devDepRequestRef) {
|
|
141
|
-
await api.runRequest({
|
|
142
|
-
id: 'dev_dep_request:' + devDepRequestRef.specifier + ':' + devDepRequestRef.hash,
|
|
143
|
-
type: _RequestTracker.requestTypes.dev_dep_request,
|
|
144
|
-
run: ({
|
|
145
|
-
api
|
|
146
|
-
}) => {
|
|
147
|
-
const devDepRequest = resolveDevDepRequestRef(devDepRequestRef);
|
|
148
|
-
for (let filePath of (0, _nullthrows().default)(devDepRequest.invalidateOnFileChange, 'DevDepRequest missing invalidateOnFileChange')) {
|
|
149
|
-
api.invalidateOnFileUpdate(filePath);
|
|
150
|
-
api.invalidateOnFileDelete(filePath);
|
|
151
|
-
}
|
|
152
|
-
for (let invalidation of (0, _nullthrows().default)(devDepRequest.invalidateOnFileCreate, 'DevDepRequest missing invalidateOnFileCreate')) {
|
|
153
|
-
api.invalidateOnFileCreate(invalidation);
|
|
154
|
-
}
|
|
155
|
-
if (devDepRequest.invalidateOnStartup) {
|
|
156
|
-
api.invalidateOnStartup();
|
|
157
|
-
}
|
|
158
|
-
api.storeResult({
|
|
159
|
-
specifier: devDepRequest.specifier,
|
|
160
|
-
resolveFrom: devDepRequest.resolveFrom,
|
|
161
|
-
hash: devDepRequest.hash,
|
|
162
|
-
additionalInvalidations: devDepRequest.additionalInvalidations
|
|
163
|
-
});
|
|
164
|
-
},
|
|
165
|
-
input: null
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// A cache of plugin dependency hashes that we've already sent to the main thread.
|
|
170
|
-
// Automatically cleared before each build.
|
|
171
|
-
const pluginCache = (0, _buildCache().createBuildCache)();
|
|
172
|
-
function getWorkerDevDepRequests(devDepRequests) {
|
|
173
|
-
return devDepRequests.map(devDepRequest => {
|
|
174
|
-
// If we've already sent a matching transformer + hash to the main thread during this build,
|
|
175
|
-
// there's no need to repeat ourselves.
|
|
176
|
-
let {
|
|
177
|
-
specifier,
|
|
178
|
-
resolveFrom,
|
|
179
|
-
hash
|
|
180
|
-
} = devDepRequest;
|
|
181
|
-
if (hash === pluginCache.get(specifier)) {
|
|
182
|
-
return {
|
|
183
|
-
type: 'ref',
|
|
184
|
-
specifier,
|
|
185
|
-
resolveFrom,
|
|
186
|
-
hash
|
|
187
|
-
};
|
|
188
|
-
} else {
|
|
189
|
-
pluginCache.set(specifier, hash);
|
|
190
|
-
return devDepRequest;
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
}
|
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.EntryResolver = void 0;
|
|
7
|
-
exports.default = createEntryRequest;
|
|
8
|
-
function _utils() {
|
|
9
|
-
const data = require("@atlaspack/utils");
|
|
10
|
-
_utils = function () {
|
|
11
|
-
return data;
|
|
12
|
-
};
|
|
13
|
-
return data;
|
|
14
|
-
}
|
|
15
|
-
function _diagnostic() {
|
|
16
|
-
const data = _interopRequireWildcard(require("@atlaspack/diagnostic"));
|
|
17
|
-
_diagnostic = function () {
|
|
18
|
-
return data;
|
|
19
|
-
};
|
|
20
|
-
return data;
|
|
21
|
-
}
|
|
22
|
-
function _path() {
|
|
23
|
-
const data = _interopRequireDefault(require("path"));
|
|
24
|
-
_path = function () {
|
|
25
|
-
return data;
|
|
26
|
-
};
|
|
27
|
-
return data;
|
|
28
|
-
}
|
|
29
|
-
function _jsonSourcemap() {
|
|
30
|
-
const data = require("@mischnic/json-sourcemap");
|
|
31
|
-
_jsonSourcemap = function () {
|
|
32
|
-
return data;
|
|
33
|
-
};
|
|
34
|
-
return data;
|
|
35
|
-
}
|
|
36
|
-
var _RequestTracker = require("../RequestTracker");
|
|
37
|
-
var _projectPath = require("../projectPath");
|
|
38
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
39
|
-
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); }
|
|
40
|
-
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; }
|
|
41
|
-
const type = 'entry_request';
|
|
42
|
-
function createEntryRequest(input) {
|
|
43
|
-
return {
|
|
44
|
-
id: `${type}:${(0, _projectPath.fromProjectPathRelative)(input)}`,
|
|
45
|
-
type: _RequestTracker.requestTypes.entry_request,
|
|
46
|
-
run,
|
|
47
|
-
input
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
async function run({
|
|
51
|
-
input,
|
|
52
|
-
api,
|
|
53
|
-
options
|
|
54
|
-
}) {
|
|
55
|
-
let entryResolver = new EntryResolver(options);
|
|
56
|
-
let filePath = (0, _projectPath.fromProjectPath)(options.projectRoot, input);
|
|
57
|
-
let result = await entryResolver.resolveEntry(filePath);
|
|
58
|
-
|
|
59
|
-
// Connect files like package.json that affect the entry
|
|
60
|
-
// resolution so we invalidate when they change.
|
|
61
|
-
for (let file of result.files) {
|
|
62
|
-
api.invalidateOnFileUpdate(file.filePath);
|
|
63
|
-
api.invalidateOnFileDelete(file.filePath);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// If the entry specifier is a glob, add a glob node so
|
|
67
|
-
// we invalidate when a new file matches.
|
|
68
|
-
for (let glob of result.globs) {
|
|
69
|
-
api.invalidateOnFileCreate({
|
|
70
|
-
glob: (0, _projectPath.toProjectPath)(options.projectRoot, glob)
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// Invalidate whenever an entry is deleted.
|
|
75
|
-
// If the entry was a glob, we'll re-evaluate it, and otherwise
|
|
76
|
-
// a proper entry error will be thrown.
|
|
77
|
-
for (let entry of result.entries) {
|
|
78
|
-
api.invalidateOnFileDelete(entry.filePath);
|
|
79
|
-
}
|
|
80
|
-
return result;
|
|
81
|
-
}
|
|
82
|
-
async function assertFile(fs, entry, relativeSource, pkgFilePath, keyPath, options) {
|
|
83
|
-
let source = _path().default.join(entry, relativeSource);
|
|
84
|
-
let stat;
|
|
85
|
-
try {
|
|
86
|
-
stat = await fs.stat(source);
|
|
87
|
-
} catch (err) {
|
|
88
|
-
let contents = await fs.readFile(pkgFilePath, 'utf8');
|
|
89
|
-
let alternatives = await (0, _utils().findAlternativeFiles)(fs, relativeSource, entry, options.projectRoot, false);
|
|
90
|
-
throw new (_diagnostic().default)({
|
|
91
|
-
diagnostic: {
|
|
92
|
-
origin: '@atlaspack/core',
|
|
93
|
-
message: (0, _diagnostic().md)`${_path().default.relative(process.cwd(), source)} does not exist.`,
|
|
94
|
-
codeFrames: [{
|
|
95
|
-
filePath: pkgFilePath,
|
|
96
|
-
codeHighlights: (0, _diagnostic().generateJSONCodeHighlights)(contents, [{
|
|
97
|
-
key: keyPath,
|
|
98
|
-
type: 'value'
|
|
99
|
-
}])
|
|
100
|
-
}],
|
|
101
|
-
hints: alternatives.map(r => {
|
|
102
|
-
return (0, _diagnostic().md)`Did you mean '__${r}__'?`;
|
|
103
|
-
})
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
if (!stat.isFile()) {
|
|
108
|
-
let contents = await fs.readFile(pkgFilePath, 'utf8');
|
|
109
|
-
throw new (_diagnostic().default)({
|
|
110
|
-
diagnostic: {
|
|
111
|
-
origin: '@atlaspack/core',
|
|
112
|
-
message: (0, _diagnostic().md)`${_path().default.relative(process.cwd(), source)} is not a file.`,
|
|
113
|
-
codeFrames: [{
|
|
114
|
-
filePath: pkgFilePath,
|
|
115
|
-
codeHighlights: (0, _diagnostic().generateJSONCodeHighlights)(contents, [{
|
|
116
|
-
key: keyPath,
|
|
117
|
-
type: 'value'
|
|
118
|
-
}])
|
|
119
|
-
}]
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
class EntryResolver {
|
|
125
|
-
constructor(options) {
|
|
126
|
-
this.options = options;
|
|
127
|
-
}
|
|
128
|
-
async resolveEntry(entry) {
|
|
129
|
-
let stat;
|
|
130
|
-
try {
|
|
131
|
-
stat = await this.options.inputFS.stat(entry);
|
|
132
|
-
} catch (err) {
|
|
133
|
-
if (!(0, _utils().isGlob)(entry)) {
|
|
134
|
-
throw new (_diagnostic().default)({
|
|
135
|
-
diagnostic: {
|
|
136
|
-
message: (0, _diagnostic().md)`Entry ${entry} does not exist`
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
let files = await (0, _utils().glob)(entry, this.options.inputFS, {
|
|
141
|
-
absolute: true,
|
|
142
|
-
onlyFiles: false
|
|
143
|
-
});
|
|
144
|
-
let results = await Promise.all(files.map(f => this.resolveEntry(_path().default.normalize(f))));
|
|
145
|
-
return results.reduce((p, res) => ({
|
|
146
|
-
entries: p.entries.concat(res.entries),
|
|
147
|
-
files: p.files.concat(res.files),
|
|
148
|
-
globs: p.globs.concat(res.globs)
|
|
149
|
-
}), {
|
|
150
|
-
entries: [],
|
|
151
|
-
files: [],
|
|
152
|
-
globs: [entry]
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
if (stat.isDirectory()) {
|
|
156
|
-
let pkg = await this.readPackage(entry);
|
|
157
|
-
if (pkg) {
|
|
158
|
-
let {
|
|
159
|
-
filePath
|
|
160
|
-
} = pkg;
|
|
161
|
-
let entries = [];
|
|
162
|
-
let files = [{
|
|
163
|
-
filePath: (0, _projectPath.toProjectPath)(this.options.projectRoot, filePath)
|
|
164
|
-
}];
|
|
165
|
-
let globs = [];
|
|
166
|
-
let targetsWithSources = 0;
|
|
167
|
-
if (pkg.targets) {
|
|
168
|
-
for (let targetName in pkg.targets) {
|
|
169
|
-
let target = pkg.targets[targetName];
|
|
170
|
-
if (target.source != null) {
|
|
171
|
-
targetsWithSources++;
|
|
172
|
-
let targetSources = Array.isArray(target.source) ? target.source : [target.source];
|
|
173
|
-
let i = 0;
|
|
174
|
-
for (let source of targetSources) {
|
|
175
|
-
let sources;
|
|
176
|
-
if ((0, _utils().isGlob)(source)) {
|
|
177
|
-
globs.push(source);
|
|
178
|
-
sources = await (0, _utils().glob)(source, this.options.inputFS, {
|
|
179
|
-
onlyFiles: true,
|
|
180
|
-
cwd: entry
|
|
181
|
-
});
|
|
182
|
-
} else {
|
|
183
|
-
sources = [source];
|
|
184
|
-
}
|
|
185
|
-
let keyPath = `/targets/${targetName}/source${Array.isArray(target.source) ? `/${i}` : ''}`;
|
|
186
|
-
for (let relativeSource of sources) {
|
|
187
|
-
let source = _path().default.join(entry, relativeSource);
|
|
188
|
-
await assertFile(this.options.inputFS, entry, relativeSource, filePath, keyPath, this.options);
|
|
189
|
-
entries.push({
|
|
190
|
-
filePath: (0, _projectPath.toProjectPath)(this.options.projectRoot, source),
|
|
191
|
-
packagePath: (0, _projectPath.toProjectPath)(this.options.projectRoot, entry),
|
|
192
|
-
target: targetName,
|
|
193
|
-
loc: {
|
|
194
|
-
filePath: (0, _projectPath.toProjectPath)(this.options.projectRoot, pkg.filePath),
|
|
195
|
-
...(0, _diagnostic().getJSONSourceLocation)(pkg.map.pointers[keyPath], 'value')
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
i++;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
let allTargetsHaveSource = targetsWithSources > 0 && pkg != null && pkg.targets != null && Object.keys(pkg.targets).length === targetsWithSources;
|
|
205
|
-
if (!allTargetsHaveSource && pkg.source != null) {
|
|
206
|
-
let pkgSources = Array.isArray(pkg.source) ? pkg.source : [pkg.source];
|
|
207
|
-
let i = 0;
|
|
208
|
-
for (let pkgSource of pkgSources) {
|
|
209
|
-
let sources;
|
|
210
|
-
if ((0, _utils().isGlob)(pkgSource)) {
|
|
211
|
-
globs.push(pkgSource);
|
|
212
|
-
sources = await (0, _utils().glob)(pkgSource, this.options.inputFS, {
|
|
213
|
-
onlyFiles: true,
|
|
214
|
-
cwd: _path().default.dirname(filePath)
|
|
215
|
-
});
|
|
216
|
-
} else {
|
|
217
|
-
sources = [pkgSource];
|
|
218
|
-
}
|
|
219
|
-
let keyPath = `/source${Array.isArray(pkg.source) ? `/${i}` : ''}`;
|
|
220
|
-
for (let relativeSource of sources) {
|
|
221
|
-
let source = _path().default.join(_path().default.dirname(filePath), relativeSource);
|
|
222
|
-
await assertFile(this.options.inputFS, entry, relativeSource, filePath, keyPath, this.options);
|
|
223
|
-
entries.push({
|
|
224
|
-
filePath: (0, _projectPath.toProjectPath)(this.options.projectRoot, source),
|
|
225
|
-
packagePath: (0, _projectPath.toProjectPath)(this.options.projectRoot, entry),
|
|
226
|
-
loc: {
|
|
227
|
-
filePath: (0, _projectPath.toProjectPath)(this.options.projectRoot, pkg.filePath),
|
|
228
|
-
...(0, _diagnostic().getJSONSourceLocation)(pkg.map.pointers[keyPath], 'value')
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
i++;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// Only return if we found any valid entries
|
|
237
|
-
if (entries.length && files.length) {
|
|
238
|
-
return {
|
|
239
|
-
entries,
|
|
240
|
-
files,
|
|
241
|
-
globs
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
throw new (_diagnostic().default)({
|
|
246
|
-
diagnostic: {
|
|
247
|
-
message: (0, _diagnostic().md)`Could not find entry: ${entry}`
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
} else if (stat.isFile()) {
|
|
251
|
-
let projectRoot = this.options.projectRoot;
|
|
252
|
-
let packagePath = (0, _utils().isDirectoryInside)(this.options.inputFS.cwd(), projectRoot) ? this.options.inputFS.cwd() : projectRoot;
|
|
253
|
-
return {
|
|
254
|
-
entries: [{
|
|
255
|
-
filePath: (0, _projectPath.toProjectPath)(this.options.projectRoot, entry),
|
|
256
|
-
packagePath: (0, _projectPath.toProjectPath)(this.options.projectRoot, packagePath)
|
|
257
|
-
}],
|
|
258
|
-
files: [],
|
|
259
|
-
globs: []
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
throw new (_diagnostic().default)({
|
|
263
|
-
diagnostic: {
|
|
264
|
-
message: (0, _diagnostic().md)`Unknown entry: ${entry}`
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
async readPackage(entry) {
|
|
269
|
-
let content, pkg;
|
|
270
|
-
let pkgFile = _path().default.join(entry, 'package.json');
|
|
271
|
-
try {
|
|
272
|
-
content = await this.options.inputFS.readFile(pkgFile, 'utf8');
|
|
273
|
-
} catch (err) {
|
|
274
|
-
return null;
|
|
275
|
-
}
|
|
276
|
-
try {
|
|
277
|
-
pkg = JSON.parse(content);
|
|
278
|
-
} catch (err) {
|
|
279
|
-
// TODO: code frame?
|
|
280
|
-
throw new (_diagnostic().default)({
|
|
281
|
-
diagnostic: {
|
|
282
|
-
message: (0, _diagnostic().md)`Error parsing ${_path().default.relative(this.options.inputFS.cwd(), pkgFile)}: ${err.message}`
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
return {
|
|
287
|
-
...pkg,
|
|
288
|
-
filePath: pkgFile,
|
|
289
|
-
map: (0, _jsonSourcemap().parse)(content, undefined, {
|
|
290
|
-
tabWidth: 1
|
|
291
|
-
})
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
exports.EntryResolver = EntryResolver;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createPackageRequest = createPackageRequest;
|
|
7
|
-
var _RequestTracker = require("../RequestTracker");
|
|
8
|
-
function _nullthrows() {
|
|
9
|
-
const data = _interopRequireDefault(require("nullthrows"));
|
|
10
|
-
_nullthrows = function () {
|
|
11
|
-
return data;
|
|
12
|
-
};
|
|
13
|
-
return data;
|
|
14
|
-
}
|
|
15
|
-
var _ConfigRequest = require("./ConfigRequest");
|
|
16
|
-
var _DevDepRequest = require("./DevDepRequest");
|
|
17
|
-
var _AtlaspackConfigRequest = _interopRequireDefault(require("./AtlaspackConfigRequest"));
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
function createPackageRequest(input) {
|
|
20
|
-
return {
|
|
21
|
-
type: _RequestTracker.requestTypes.package_request,
|
|
22
|
-
id: input.bundleGraph.getHash(input.bundle),
|
|
23
|
-
run,
|
|
24
|
-
input
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
async function run({
|
|
28
|
-
input,
|
|
29
|
-
api,
|
|
30
|
-
farm
|
|
31
|
-
}) {
|
|
32
|
-
let {
|
|
33
|
-
bundleGraphReference,
|
|
34
|
-
optionsRef,
|
|
35
|
-
bundle,
|
|
36
|
-
useMainThread
|
|
37
|
-
} = input;
|
|
38
|
-
let runPackage = farm.createHandle('runPackage', useMainThread);
|
|
39
|
-
let start = Date.now();
|
|
40
|
-
let {
|
|
41
|
-
devDeps,
|
|
42
|
-
invalidDevDeps
|
|
43
|
-
} = await (0, _DevDepRequest.getDevDepRequests)(api);
|
|
44
|
-
let {
|
|
45
|
-
cachePath
|
|
46
|
-
} = (0, _nullthrows().default)(await api.runRequest((0, _AtlaspackConfigRequest.default)()));
|
|
47
|
-
let {
|
|
48
|
-
devDepRequests,
|
|
49
|
-
configRequests,
|
|
50
|
-
bundleInfo,
|
|
51
|
-
invalidations
|
|
52
|
-
} = await runPackage({
|
|
53
|
-
bundle,
|
|
54
|
-
bundleGraphReference,
|
|
55
|
-
optionsRef,
|
|
56
|
-
configCachePath: cachePath,
|
|
57
|
-
previousDevDeps: devDeps,
|
|
58
|
-
invalidDevDeps,
|
|
59
|
-
previousInvalidations: api.getInvalidations()
|
|
60
|
-
});
|
|
61
|
-
for (let devDepRequest of devDepRequests) {
|
|
62
|
-
await (0, _DevDepRequest.runDevDepRequest)(api, devDepRequest);
|
|
63
|
-
}
|
|
64
|
-
for (let configRequest of configRequests) {
|
|
65
|
-
await (0, _ConfigRequest.runConfigRequest)(api, configRequest);
|
|
66
|
-
}
|
|
67
|
-
for (let invalidation of invalidations) {
|
|
68
|
-
switch (invalidation.type) {
|
|
69
|
-
case 'file':
|
|
70
|
-
api.invalidateOnFileUpdate(invalidation.filePath);
|
|
71
|
-
api.invalidateOnFileDelete(invalidation.filePath);
|
|
72
|
-
break;
|
|
73
|
-
case 'env':
|
|
74
|
-
api.invalidateOnEnvChange(invalidation.key);
|
|
75
|
-
break;
|
|
76
|
-
case 'option':
|
|
77
|
-
api.invalidateOnOptionChange(invalidation.key);
|
|
78
|
-
break;
|
|
79
|
-
default:
|
|
80
|
-
throw new Error(`Unknown invalidation type: ${invalidation.type}`);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// $FlowFixMe[cannot-write] time is marked read-only, but this is the exception
|
|
85
|
-
bundleInfo.time = Date.now() - start;
|
|
86
|
-
api.storeResult(bundleInfo);
|
|
87
|
-
return bundleInfo;
|
|
88
|
-
}
|