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

support of global compilation mode on top of commonJS #219

Closed
wants to merge 1 commit into from

Conversation

b-laporte
Copy link
Member

This small PR introduces a new compilation option called mode that allows to choose between "commonJS" and "global":

// default mode is "commonJS"
// default globalRef is "hsp" (only used when mode is "global")
var r = compiler.compile(sample.template, "template1", {mode:"global", globalRef:"foo"});

In practice this change cannot be used yet as we have to package and distribute the hashspace runtime as a global variable first (e.g. on ariatempaltes CDN). But when this is done, I would be in favour of putting "global" as default compilation mode (of course hashspace Getting Started should be updated accordingly)

Note: I chose to have an enum type for mode as I guess we will want to support "es6" as a new mode soon, so a basic boolean was not enough...

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) when pulling 822b483 on b-laporte:hsp-global into 729511f on ariatemplates:master.

@benouat
Copy link
Member

benouat commented Jun 30, 2014

I am fine with this PR.
Nevertheless, I think we should investigate the road of universal module definition, so we don't have to bother the end-user with a compilation option...

They could simply use the lib the way they feel comfortable, and it could work automagically.

PS: @b-laporte I am glad you change you mind about "global" being the default one !

@PK1A
Copy link
Contributor

PK1A commented Jun 30, 2014

+100 (wow, I never thought I will be happy from the fact of introducing global variables :-)). In the longer run I think we shouldn't need this mode switch at all as we could go with the UMD definition:

I've started to look into Browserify a bit and it can surely package things using UMD. I guess we will need some fiddling with the build options, but sounds feasible for now.

@PK1A
Copy link
Contributor

PK1A commented Jun 30, 2014

One more observation - fixing compiler is not enough since the transpiler generates require for the json.$set dependency.

@b-laporte b-laporte closed this in a223a0b Jul 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants