Skip to content

Commit c7a9d61

Browse files
author
Ben Newman
committed
Allow processFilesFor{Target,Bundle,Package} to return a Promise.
This paves the way for compiler plugins to use normal async/await rather than using fibers and/or futures to wait for async compilation to finish.
1 parent 9cc978e commit c7a9d61

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

tools/isobuild/bundler.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,10 +1246,12 @@ class Target {
12461246
buildmessage.enterJob('minifying app code', function () {
12471247
try {
12481248
var markedMinifier = buildmessage.markBoundary(minifier);
1249-
markedMinifier(staticFiles, { minifyMode });
1250-
dynamicFiles.forEach(file => {
1251-
markedMinifier([file], { minifyMode });
1252-
});
1249+
Promise.all([
1250+
markedMinifier(staticFiles, { minifyMode }),
1251+
...dynamicFiles.map(
1252+
file => markedMinifier([file], { minifyMode })
1253+
),
1254+
]).await();
12531255
} catch (e) {
12541256
buildmessage.exception(e);
12551257
}
@@ -1497,7 +1499,7 @@ class ClientTarget extends Target {
14971499
buildmessage.enterJob('minifying app stylesheet', function () {
14981500
try {
14991501
const markedMinifier = buildmessage.markBoundary(minifier);
1500-
markedMinifier(sources, { minifyMode });
1502+
Promise.await(markedMinifier(sources, { minifyMode }));
15011503
} catch (e) {
15021504
buildmessage.exception(e);
15031505
}

tools/isobuild/compiler-plugin.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,9 @@ export class CompilerPluginProcessor {
187187
var markedMethod = buildmessage.markBoundary(
188188
sourceProcessor.userPlugin.processFilesForTarget.bind(
189189
sourceProcessor.userPlugin));
190+
190191
try {
191-
markedMethod(inputFiles);
192+
Promise.await(markedMethod(inputFiles));
192193
} catch (e) {
193194
buildmessage.exception(e);
194195
}

tools/isobuild/compiler.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,9 @@ function runLinters({inputSourceArch, isopackCache, sources,
840840
try {
841841
var markedLinter = buildmessage.markBoundary(linter.bind(
842842
sourceProcessor.userPlugin));
843-
markedLinter(sourcesToLint, { globals: globalImports });
843+
Promise.await(markedLinter(sourcesToLint, {
844+
globals: globalImports
845+
}));
844846
} catch (e) {
845847
buildmessage.exception(e);
846848
}
@@ -1041,4 +1043,9 @@ export const KNOWN_ISOBUILD_FEATURE_PACKAGES = {
10411043
// This package requires functionality introduced in meteor-tool@1.5.0
10421044
// to enable dynamic module fetching via import(...).
10431045
'isobuild:dynamic-import': ['1.5.0'],
1046+
1047+
// This package ensures that processFilesFor{Bundle,Target,Package} are
1048+
// allowed to return a Promise instead of having to await async
1049+
// compilation using fibers and/or futures.
1050+
'isobuild:async-plugins': ['1.6.1'],
10441051
};

0 commit comments

Comments
 (0)