Skip to content

Add support for bundling function declarations#4044

Merged
thomashoneyman merged 5 commits intopurescript:masterfrom
kl0tl:add-support-for-bundling-function-declarations
Jul 20, 2021
Merged

Add support for bundling function declarations#4044
thomashoneyman merged 5 commits intopurescript:masterfrom
kl0tl:add-support-for-bundling-function-declarations

Conversation

@kl0tl
Copy link
Copy Markdown
Member

@kl0tl kl0tl commented Apr 4, 2021

Description of the change

purs bundle does not consider the dependencies of function declarations because the compiler always emit variable declarations. This has unfortunate consequences when optimizing foreign modules:

"use strict";

var x = 0;

function foo() {
  return x;
}

exports.foo = foo;

If the dependency of foo on x isn’t discovered, x appears unused and is removed from the bundle!

Fix #4039, fix #3259 and fix #2290.


Checklist:

  • Added the change to the changelog's "Unreleased" section with a reference to this PR (e.g. "- Made a change (#0000)")
  • Linked any existing issues or proposals that this pull request should close
  • Updated or added relevant documentation
  • Added a test for the contribution (if applicable)

@rhendric
Copy link
Copy Markdown
Member

This PR spans releases, so it'll need a rebase and the changelog entry will need to be moved to the current Unreleased section.

@kl0tl kl0tl force-pushed the add-support-for-bundling-function-declarations branch from 563cf40 to f928184 Compare June 30, 2021 08:39
@hdgarrood
Copy link
Copy Markdown
Contributor

Is the changelog entry the only thing preventing merging here now?

@kl0tl
Copy link
Copy Markdown
Member Author

kl0tl commented Jul 20, 2021

No more!

@kl0tl kl0tl force-pushed the add-support-for-bundling-function-declarations branch from 2a257e2 to 9b35823 Compare July 20, 2021 15:59
@JordanMartinez
Copy link
Copy Markdown
Contributor

Just FYI. This seems to have introduced a regression. See purescript-contrib/purescript-arraybuffer/issues/34. Should I open a new issue? Or is there one already?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

6 participants