Naming a constructor PS breaks the javascript#3533
Conversation
PS breaks the javascripPS breaks the javascript
|
I agree that having some tests would be good. Are you volunteering to add some? I'm very happy to help if you have any questions. |
|
It sounds like morning fun if we do not mind me taking some time. An outline:
|
|
I think a tests/purs/bundle directory sounds great. |
|
(Fixes #3505) |
105cd48 to
38a0b55
Compare
|
@hdgarrood |
hdgarrood
left a comment
There was a problem hiding this comment.
Thanks! I still need to get my head around the actual changes but in the meantime, here's a few minor comments.
This doesn't bother me, I think what we have here is fine for now. |
38a0b55 to
83be18c
Compare
|
Thanks for all the minor comments, they are applied. |
|
I've now reviewed this properly and it looks good to me, although I have one small suggestion. Instead of e.g. could we perhaps generate which I think should be equivalent, but is a bit clearer? |
|
Oh and one more: how about using $PS as the name of the argument for the IIFE function for each module in the output? Then we should be able to avoid collisions with names from PureScript values entirely, rather than relying on slightly arcane details of JS scoping in cases of collisions. |
365e458 to
7f273f6
Compare
|
All suggestions included in the PR. |
|
Sorry, I should have been clearer: what I mean is that the default bundle namespace should continue to be PS, but the name given to the argument of each iife for each module should be something which couldn’t clash with any purescript name. So for example you might get var PS = PS || {};
function($PS) {
// Generated by purs version 0.12.2
"use strict";
var exports = $PS["Effect.Console"] = $PS["Effect.Console"] || {};
var $foreign = $PS["Effect.Console"];
var Data_Show = $PS["Data.Show"];
var Data_Unit = $PS["Data.Unit"];
var Effect = $PS["Effect"];
exports["log"] = $foreign.log;
})(PS);So the namespace object is always referred to as $PS inside each iife, regardless of the namespace CLI option. I’d prefer to leave the tests as they were before. |
|
Oh, that sounds reasonable. The only difference to the example is in the namespace declaration. it is as it was before. |
|
Yes, thanks, I think the initial namespace declaration should stay as it is, Did you make a commit locally which you haven't pushed yet? It looks like there aren't any new commits to this branch since my last review comment. |
76ffbd0 to
9f6ccdf
Compare
|
I have rebased and pushed. |
9f6ccdf to
aa843df
Compare
|
The |
aa843df to
9a0e9c9
Compare
|
Thanks for noticing. |
Introduced test for psc-bundle. reference
|
Thanks! |
I have fixed the PS constructor braking the exports by changing the IIFE argument from exports to the PS module object.
There are no automated tests for the psc-bundle and I have not added one. Maybe they should be introduced?
Fragment of an output is: