Skip to content

Commit ce4328c

Browse files
authored
Update flow to 0.180.0 (#8201)
1 parent 597716a commit ce4328c

File tree

14 files changed

+50
-37
lines changed

14 files changed

+50
-37
lines changed

.flowconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ untyped-import
3636
untyped-type-import
3737

3838
[version]
39-
0.176.3
39+
0.180.0

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"@types/node": "^15.12.4",
4444
"cross-env": "^7.0.0",
4545
"eslint": "^7.20.0",
46-
"flow-bin": "0.176.3",
46+
"flow-bin": "0.180.0",
4747
"glob": "^7.1.6",
4848
"gulp": "^4.0.2",
4949
"gulp-babel": "^8.0.0",
@@ -69,4 +69,4 @@
6969
"type": "opencollective",
7070
"url": "https://opencollective.com/parcel"
7171
}
72-
}
72+
}

packages/core/cache/src/IDBCache.browser.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ export class IDBCache implements Cache {
3131
}
3232

3333
serialize(): {||} {
34-
return {...null};
34+
return {
35+
/*::...null*/
36+
};
3537
}
3638

3739
static deserialize(): IDBCache {

packages/core/core/src/Environment.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ export function createEnvironment({
3131
shouldScopeHoist = false,
3232
sourceMap,
3333
loc,
34-
}: EnvironmentOpts = {}): Environment {
34+
}: EnvironmentOpts = {
35+
/*::...null*/
36+
}): Environment {
3537
if (context == null) {
3638
if (engines?.node) {
3739
context = 'node';

packages/core/core/src/Parcel.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ export default class Parcel {
248248
}: {|
249249
signal?: AbortSignal,
250250
startTime?: number,
251-
|} = {}): Promise<BuildEvent> {
251+
|} = {
252+
/*::...null*/
253+
}): Promise<BuildEvent> {
252254
this.#requestTracker.setSignal(signal);
253255
let options = nullthrows(this.#resolvedOptions);
254256
try {

packages/core/core/src/requests/ParcelConfigRequest.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,9 @@ export async function processConfig(
340340
configFile.resolveFrom,
341341
),
342342
}
343-
: {...null}),
343+
: {
344+
/*::...null*/
345+
}),
344346
resolvers: processPipeline(
345347
options,
346348
configFile.resolvers,

packages/core/core/src/requests/TargetRequest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,14 +478,14 @@ export class TargetResolver {
478478
// If there is a separate `browser` target, or an `engines.node` field but no browser targets, then
479479
// the `main` and `module` targets refer to node, otherwise browser.
480480
let mainContext =
481-
pkg.browser ?? pkgTargets.browser ?? (node != null && !browsers)
481+
pkg.browser ?? pkgTargets.browser ?? (node != null && browsers == null)
482482
? 'node'
483483
: 'browser';
484484
let moduleContext =
485485
pkg.browser ?? pkgTargets.browser ? 'browser' : mainContext;
486486

487487
let defaultEngines = this.options.defaultTargetOptions.engines;
488-
let context = browsers ?? !node ? 'browser' : 'node';
488+
let context = browsers ?? node == null ? 'browser' : 'node';
489489
if (context === 'browser' && pkgEngines.browsers == null) {
490490
pkgEngines = {
491491
...pkgEngines,

packages/core/core/src/resolveOptions.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ export default async function resolveOptions(
173173
publicUrl,
174174
...(distDir != null
175175
? {distDir: toProjectPath(projectRoot, distDir)}
176-
: {...null}),
176+
: {
177+
/*::...null*/
178+
}),
177179
engines: initialOptions?.defaultTargetOptions?.engines,
178180
outputFormat: initialOptions?.defaultTargetOptions?.outputFormat,
179181
isLibrary: initialOptions?.defaultTargetOptions?.isLibrary,

packages/core/types/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,13 @@ export type PackageJSON = {
258258
types?: FilePath,
259259
browser?: FilePath | {[FilePath]: FilePath | boolean, ...},
260260
source?: FilePath | Array<FilePath>,
261-
alias?: {[PackageName | FilePath | Glob]: PackageName | FilePath, ...},
261+
alias?: {
262+
[PackageName | FilePath | Glob]:
263+
| PackageName
264+
| FilePath
265+
| {|global: string|},
266+
...
267+
},
262268
browserslist?: Array<string> | {[string]: Array<string>},
263269
engines?: Engines,
264270
targets?: {[string]: PackageTargetDescriptor, ...},

packages/core/workers/src/process/ProcessChild.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export default class ProcessChild implements ChildImpl {
3737
let processSend = nullthrows(process.send).bind(process);
3838
processSend(serialize(data).toString('base64'), err => {
3939
if (err && err instanceof Error) {
40+
// $FlowFixMe[prop-missing]
4041
if (err.code === 'ERR_IPC_CHANNEL_CLOSED') {
4142
// IPC connection closed
4243
// no need to keep the worker running if it can't send or receive data

packages/transformers/html/src/inline.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,15 @@ export default function extractInlineAssets(
5757

5858
let outputFormat = 'global';
5959
let sourceType = 'script';
60-
if (node.attrs.type === 'module') {
60+
let attrs = node.attrs;
61+
if (attrs && attrs.type === 'module') {
6162
if (
6263
asset.env.shouldScopeHoist &&
6364
asset.env.supports('esmodules', true)
6465
) {
6566
outputFormat = 'esmodule';
6667
} else {
67-
delete node.attrs.type;
68+
delete attrs.type;
6869
}
6970

7071
sourceType = 'module';

packages/transformers/svg/src/inline.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,25 @@ export default function extractInlineAssets(
6464
return node;
6565
}
6666

67-
if (!node.attrs) {
68-
node.attrs = {};
67+
let attrs = node.attrs;
68+
if (!attrs) {
69+
attrs = {};
70+
node.attrs = attrs;
6971
}
7072

7173
// Inform packager to remove type, since CSS and JS are the defaults.
72-
delete node.attrs.type;
74+
delete attrs.type;
7375

7476
let parcelKey;
7577
// allow a script/style tag to declare its key
76-
if (node.attrs['data-parcel-key']) {
77-
parcelKey = node.attrs['data-parcel-key'];
78+
if (attrs['data-parcel-key']) {
79+
parcelKey = attrs['data-parcel-key'];
7880
} else {
7981
parcelKey = hashString(`${asset.id}:${key++}`);
8082
}
8183

8284
// insert parcelId to allow us to retrieve node during packaging
83-
node.attrs['data-parcel-key'] = parcelKey;
85+
attrs['data-parcel-key'] = parcelKey;
8486
asset.setAST(ast); // mark dirty
8587

8688
asset.addDependency({

packages/utils/node-resolver-core/src/NodeResolver.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ type ResolvedFile = {|
4949
pkg: InternalPackageJSON | null,
5050
|};
5151

52-
type Aliases =
53-
| string
54-
| {[string]: string, ...}
55-
| {[string]: string | boolean, ...};
52+
type Aliases = string | {+[string]: string | boolean | {|global: string|}, ...};
5653
type ResolvedAlias = {|
5754
type: 'file' | 'global',
5855
sourcePath: FilePath,
@@ -1117,7 +1114,7 @@ export default class NodeResolver {
11171114
if (typeof alias === 'string' && subPath) {
11181115
let isRelative = alias.startsWith('./');
11191116
// Append the filename back onto the aliased module.
1120-
alias = path.posix.join(alias, subPath);
1117+
alias = (path.posix.join(alias, subPath): string);
11211118
// because of path.join('./nested', 'sub') === 'nested/sub'
11221119
if (isRelative) alias = './' + alias;
11231120
}
@@ -1133,7 +1130,7 @@ export default class NodeResolver {
11331130
};
11341131
}
11351132

1136-
if (alias instanceof Object) {
1133+
if (alias && typeof alias === 'object') {
11371134
if (alias.global) {
11381135
if (typeof alias.global !== 'string' || alias.global.length === 0) {
11391136
throw new ThrowableDiagnostic({
@@ -1149,8 +1146,6 @@ export default class NodeResolver {
11491146
sourcePath: pkg.pkgfile,
11501147
resolved: alias.global,
11511148
};
1152-
} else if (alias.fileName) {
1153-
alias = alias.fileName;
11541149
}
11551150
}
11561151

@@ -1171,7 +1166,10 @@ export default class NodeResolver {
11711166
return null;
11721167
}
11731168

1174-
lookupAlias(aliases: Aliases, filename: FilePath): null | boolean | string {
1169+
lookupAlias(
1170+
aliases: Aliases,
1171+
filename: FilePath,
1172+
): null | boolean | string | {|global: string|} {
11751173
if (typeof aliases !== 'object') {
11761174
return null;
11771175
}

yarn.lock

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6050,10 +6050,10 @@ flatted@^3.1.0:
60506050
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.1.1.tgz#c4b489e80096d9df1dfc97c79871aea7c617c469"
60516051
integrity sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==
60526052

6053-
flow-bin@0.176.3:
6054-
version "0.176.3"
6055-
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.176.3.tgz#d32de04e044ab474afe543b9fd245608bb6a6ac8"
6056-
integrity sha512-lbNqgjr2GlGLAEVp5+dhG4LdnFE7ekbvVNifAdlvTx58/nE8GrCOMiUwEQy4dLnfL2NIRMk2dbEVTrugeQJ3mA==
6053+
flow-bin@0.180.0:
6054+
version "0.180.0"
6055+
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.180.0.tgz#7a26f3a0cff61e386267e72ef7971d1af73e317a"
6056+
integrity sha512-jEZoIwOxzrtQ0erUu94nEzlqUoX7OAMeVs0CjO0rN6b7SDBhI5IysVRvGSQkkFWBJpy5VQ9lvzBYzq5Sq9vcmg==
60576057

60586058
flush-write-stream@^1.0.0, flush-write-stream@^1.0.2:
60596059
version "1.1.1"
@@ -7129,11 +7129,6 @@ iferr@^0.1.5:
71297129
resolved "https://registry.yarnpkg.com/iferr/-/iferr-0.1.5.tgz#c60eed69e6d8fdb6b3104a1fcbca1c192dc5b501"
71307130
integrity sha1-xg7taebY/bazEEofy8ocGS3FtQE=
71317131

7132-
iferr@^1.0.2:
7133-
version "1.0.2"
7134-
resolved "https://registry.yarnpkg.com/iferr/-/iferr-1.0.2.tgz#e9fde49a9da06dc4a4194c6c9ed6d08305037a6d"
7135-
integrity sha512-9AfeLfji44r5TKInjhz3W9DyZI1zR1JAf2hVBMGhddAKPqBsupb89jGfbCTHIGZd6fGZl9WlHdn4AObygyMKwg==
7136-
71377132
ignore-walk@^3.0.1:
71387133
version "3.0.3"
71397134
resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.3.tgz#017e2447184bfeade7c238e4aefdd1e8f95b1e37"

0 commit comments

Comments
 (0)