Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Observe side-effects in second argument of Array.from #3604

Merged
merged 1 commit into from May 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Chunk.ts
Expand Up @@ -291,13 +291,13 @@ export default class Chunk {
}
}
for (const module of this.entryModules) {
const requiredFacades: FacadeName[] = [...module.userChunkNames].map(name => ({
const requiredFacades: FacadeName[] = Array.from(module.userChunkNames, name => ({
name
}));
if (requiredFacades.length === 0 && module.isUserDefinedEntryPoint) {
requiredFacades.push({});
}
requiredFacades.push(...[...module.chunkFileNames].map(fileName => ({ fileName })));
requiredFacades.push(...Array.from(module.chunkFileNames, fileName => ({ fileName })));
if (requiredFacades.length === 0) {
requiredFacades.push({});
}
Expand Down Expand Up @@ -416,7 +416,7 @@ export default class Chunk {
}

getDynamicImportIds(): string[] {
return [...this.dynamicDependencies].map(chunk => chunk.id as string);
return Array.from(this.dynamicDependencies, chunk => chunk.id as string);
}

getExportNames(): string[] {
Expand All @@ -426,7 +426,7 @@ export default class Chunk {
}

getImportIds(): string[] {
return [...this.dependencies].map(chunk => chunk.id as string);
return Array.from(this.dependencies, chunk => chunk.id as string);
}

getRenderedHash(outputPluginDriver: PluginDriver): string {
Expand Down
2 changes: 1 addition & 1 deletion src/Module.ts
Expand Up @@ -717,7 +717,7 @@ export default class Module {
ast: this.esTreeAst,
code: this.code,
customTransformCache: this.customTransformCache,
dependencies: [...this.dependencies].map(module => module.id),
dependencies: Array.from(this.dependencies, module => module.id),
id: this.id,
moduleSideEffects: this.moduleSideEffects,
originalCode: this.originalCode,
Expand Down
2 changes: 1 addition & 1 deletion src/ModuleLoader.ts
Expand Up @@ -234,7 +234,7 @@ export class ModuleLoader {

private fetchAllDependencies(module: Module): Promise<unknown> {
return Promise.all([
...[...module.sources].map(async source => {
...Array.from(module.sources, async source => {
const resolution = await this.fetchResolvedDependency(
source,
module.id,
Expand Down
2 changes: 1 addition & 1 deletion src/ast/nodes/shared/knownGlobals.ts
Expand Up @@ -76,7 +76,7 @@ const knownGlobals: GlobalDescription = {
// @ts-ignore
__proto__: null,
[ValueProperties]: IMPURE,
from: PF,
from: O,
isArray: PF,
of: PF,
prototype: O
Expand Down
8 changes: 8 additions & 0 deletions test/function/samples/array-from-side-effect/_config.js
@@ -0,0 +1,8 @@
const assert = require('assert');

module.exports = {
description: 'Observes side-effects in Array.from',
exports(exports) {
assert.strictEqual(exports.x, 7);
}
};
3 changes: 3 additions & 0 deletions test/function/samples/array-from-side-effect/main.js
@@ -0,0 +1,3 @@
export let x = 1;
const list = [1, 2, 3];
Array.from(list, v => (x += v));