Skip to content

Commit

Permalink
Update flow to 0.180.0 (#8201)
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed Jun 14, 2022
1 parent 597716a commit ce4328c
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ untyped-import
untyped-type-import

[version]
0.176.3
0.180.0
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@types/node": "^15.12.4",
"cross-env": "^7.0.0",
"eslint": "^7.20.0",
"flow-bin": "0.176.3",
"flow-bin": "0.180.0",
"glob": "^7.1.6",
"gulp": "^4.0.2",
"gulp-babel": "^8.0.0",
Expand All @@ -69,4 +69,4 @@
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
}
}
4 changes: 3 additions & 1 deletion packages/core/cache/src/IDBCache.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export class IDBCache implements Cache {
}

serialize(): {||} {
return {...null};
return {
/*::...null*/
};
}

static deserialize(): IDBCache {
Expand Down
4 changes: 3 additions & 1 deletion packages/core/core/src/Environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export function createEnvironment({
shouldScopeHoist = false,
sourceMap,
loc,
}: EnvironmentOpts = {}): Environment {
}: EnvironmentOpts = {
/*::...null*/
}): Environment {
if (context == null) {
if (engines?.node) {
context = 'node';
Expand Down
4 changes: 3 additions & 1 deletion packages/core/core/src/Parcel.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ export default class Parcel {
}: {|
signal?: AbortSignal,
startTime?: number,
|} = {}): Promise<BuildEvent> {
|} = {
/*::...null*/
}): Promise<BuildEvent> {
this.#requestTracker.setSignal(signal);
let options = nullthrows(this.#resolvedOptions);
try {
Expand Down
4 changes: 3 additions & 1 deletion packages/core/core/src/requests/ParcelConfigRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,9 @@ export async function processConfig(
configFile.resolveFrom,
),
}
: {...null}),
: {
/*::...null*/
}),
resolvers: processPipeline(
options,
configFile.resolvers,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/core/src/requests/TargetRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,14 +478,14 @@ export class TargetResolver {
// If there is a separate `browser` target, or an `engines.node` field but no browser targets, then
// the `main` and `module` targets refer to node, otherwise browser.
let mainContext =
pkg.browser ?? pkgTargets.browser ?? (node != null && !browsers)
pkg.browser ?? pkgTargets.browser ?? (node != null && browsers == null)
? 'node'
: 'browser';
let moduleContext =
pkg.browser ?? pkgTargets.browser ? 'browser' : mainContext;

let defaultEngines = this.options.defaultTargetOptions.engines;
let context = browsers ?? !node ? 'browser' : 'node';
let context = browsers ?? node == null ? 'browser' : 'node';
if (context === 'browser' && pkgEngines.browsers == null) {
pkgEngines = {
...pkgEngines,
Expand Down
4 changes: 3 additions & 1 deletion packages/core/core/src/resolveOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ export default async function resolveOptions(
publicUrl,
...(distDir != null
? {distDir: toProjectPath(projectRoot, distDir)}
: {...null}),
: {
/*::...null*/
}),
engines: initialOptions?.defaultTargetOptions?.engines,
outputFormat: initialOptions?.defaultTargetOptions?.outputFormat,
isLibrary: initialOptions?.defaultTargetOptions?.isLibrary,
Expand Down
8 changes: 7 additions & 1 deletion packages/core/types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,13 @@ export type PackageJSON = {
types?: FilePath,
browser?: FilePath | {[FilePath]: FilePath | boolean, ...},
source?: FilePath | Array<FilePath>,
alias?: {[PackageName | FilePath | Glob]: PackageName | FilePath, ...},
alias?: {
[PackageName | FilePath | Glob]:
| PackageName
| FilePath
| {|global: string|},
...
},
browserslist?: Array<string> | {[string]: Array<string>},
engines?: Engines,
targets?: {[string]: PackageTargetDescriptor, ...},
Expand Down
1 change: 1 addition & 0 deletions packages/core/workers/src/process/ProcessChild.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default class ProcessChild implements ChildImpl {
let processSend = nullthrows(process.send).bind(process);
processSend(serialize(data).toString('base64'), err => {
if (err && err instanceof Error) {
// $FlowFixMe[prop-missing]
if (err.code === 'ERR_IPC_CHANNEL_CLOSED') {
// IPC connection closed
// no need to keep the worker running if it can't send or receive data
Expand Down
5 changes: 3 additions & 2 deletions packages/transformers/html/src/inline.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,15 @@ export default function extractInlineAssets(

let outputFormat = 'global';
let sourceType = 'script';
if (node.attrs.type === 'module') {
let attrs = node.attrs;
if (attrs && attrs.type === 'module') {
if (
asset.env.shouldScopeHoist &&
asset.env.supports('esmodules', true)
) {
outputFormat = 'esmodule';
} else {
delete node.attrs.type;
delete attrs.type;
}

sourceType = 'module';
Expand Down
14 changes: 8 additions & 6 deletions packages/transformers/svg/src/inline.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,25 @@ export default function extractInlineAssets(
return node;
}

if (!node.attrs) {
node.attrs = {};
let attrs = node.attrs;
if (!attrs) {
attrs = {};
node.attrs = attrs;
}

// Inform packager to remove type, since CSS and JS are the defaults.
delete node.attrs.type;
delete attrs.type;

let parcelKey;
// allow a script/style tag to declare its key
if (node.attrs['data-parcel-key']) {
parcelKey = node.attrs['data-parcel-key'];
if (attrs['data-parcel-key']) {
parcelKey = attrs['data-parcel-key'];
} else {
parcelKey = hashString(`${asset.id}:${key++}`);
}

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

asset.addDependency({
Expand Down
16 changes: 7 additions & 9 deletions packages/utils/node-resolver-core/src/NodeResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ type ResolvedFile = {|
pkg: InternalPackageJSON | null,
|};

type Aliases =
| string
| {[string]: string, ...}
| {[string]: string | boolean, ...};
type Aliases = string | {+[string]: string | boolean | {|global: string|}, ...};
type ResolvedAlias = {|
type: 'file' | 'global',
sourcePath: FilePath,
Expand Down Expand Up @@ -1117,7 +1114,7 @@ export default class NodeResolver {
if (typeof alias === 'string' && subPath) {
let isRelative = alias.startsWith('./');
// Append the filename back onto the aliased module.
alias = path.posix.join(alias, subPath);
alias = (path.posix.join(alias, subPath): string);
// because of path.join('./nested', 'sub') === 'nested/sub'
if (isRelative) alias = './' + alias;
}
Expand All @@ -1133,7 +1130,7 @@ export default class NodeResolver {
};
}

if (alias instanceof Object) {
if (alias && typeof alias === 'object') {
if (alias.global) {
if (typeof alias.global !== 'string' || alias.global.length === 0) {
throw new ThrowableDiagnostic({
Expand All @@ -1149,8 +1146,6 @@ export default class NodeResolver {
sourcePath: pkg.pkgfile,
resolved: alias.global,
};
} else if (alias.fileName) {
alias = alias.fileName;
}
}

Expand All @@ -1171,7 +1166,10 @@ export default class NodeResolver {
return null;
}

lookupAlias(aliases: Aliases, filename: FilePath): null | boolean | string {
lookupAlias(
aliases: Aliases,
filename: FilePath,
): null | boolean | string | {|global: string|} {
if (typeof aliases !== 'object') {
return null;
}
Expand Down
13 changes: 4 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6050,10 +6050,10 @@ flatted@^3.1.0:
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.1.1.tgz#c4b489e80096d9df1dfc97c79871aea7c617c469"
integrity sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==

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

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

iferr@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/iferr/-/iferr-1.0.2.tgz#e9fde49a9da06dc4a4194c6c9ed6d08305037a6d"
integrity sha512-9AfeLfji44r5TKInjhz3W9DyZI1zR1JAf2hVBMGhddAKPqBsupb89jGfbCTHIGZd6fGZl9WlHdn4AObygyMKwg==

ignore-walk@^3.0.1:
version "3.0.3"
resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.3.tgz#017e2447184bfeade7c238e4aefdd1e8f95b1e37"
Expand Down

0 comments on commit ce4328c

Please sign in to comment.