CodeKit icon indicating copy to clipboard operation
CodeKit copied to clipboard

CK Seemingly messing with a file I don't want it to!

Open mattpilott opened this issue 9 years ago • 18 comments

Quick, short summary: I am including the DOMtastic library to bootstrap my js components and I think CodeKit is altering the code of DOMtastic when all I want CK to do is concatenate. This one may be a little tricky to explain but if i pull DOMtastic out into its own script tag it works as it should. It is my very first CK prepend rule so should work a treat

Expected results: DOMtastic to work just like it would in its own script file.

Actual results: 4192db84-9b70-11e6-8186-48bf24de2315

Exact steps to reproduce: Create a new project with an index and a script file, in the script file write a CK prepend rule for DOMtastic, set that file to not process or minify or transpile or anything (not sure if this is all needed) Then go to your script.js and set that to transpile and minify, check that DOMtastic is included and that the shield is unticked. Compile and test with this line at the end of your script.js $('body').addClass('success');

A link to download a simplified project or file that shows the issue: site.zip

Your configuration (any details about your system that you think might be relevant)

mattpilott avatar Oct 30 '16 13:10 mattpilott

Babel is turning all top level this to undefined.

To prevent this: babel --blacklist strict the-script-thats-not-a-module.js

Source: https://github.com/babel/babel.github.io/blob/862b43db93e48762671267034a50c30c00e433e2/docs/faq.md#why-is-this-being-remapped-to-undefined

subhaze avatar Oct 30 '16 15:10 subhaze

Sorry @subhaze where do I put this?

mattpilott avatar Oct 30 '16 15:10 mattpilott

Oh sorry, that was more of a note for @bdkjones. Only way you could do this would be bypassing CK's config completely.

subhaze avatar Oct 30 '16 15:10 subhaze

Ah I see, I'll hold fire until @bdkjones can take a look, essentially if i can tell CK to just plain ignore an include and simply concat the code but not process or minify or transpile, that would be ideal especially in cases where I'm bootstrapping my code with polyfills or micro libraries.

Thanks!

mattpilott avatar Oct 30 '16 15:10 mattpilott

Select your base JS file (the one that prepends the others) and turn off transpiling for that file. It will affect the entire chain.

bdkjones avatar Oct 30 '16 19:10 bdkjones

Ah ha! So i'm thinking about it the wrong way round, no transpiling, minifying on the main file but set the rules per include. I shall try it now good sir

mattpilott avatar Oct 30 '16 19:10 mattpilott

mmm, close. The rules for the BASE file apply to the entire chain.

bdkjones avatar Oct 30 '16 20:10 bdkjones

So upon playing I can see that I don't have an option but to apply transpiling and minification to the base/main js file. The only way I can see this working is to create an arbitrary js file, for the sole purpose of including files that need transpiling. Then have another file which concatenates my bootstrap (in this case DOMtastic) and the base/main js file that does not transpile. Is this the case?

mattpilott avatar Oct 30 '16 20:10 mattpilott

or i suppose i could create processed versions of every module and include those as an alternative

mattpilott avatar Oct 30 '16 20:10 mattpilott

Does Babel not have inline comments that can make it skip transpiling? If it does, the ideal solution would be to wrap your prepend statement in those comments.

bdkjones avatar Oct 30 '16 20:10 bdkjones

Just looking now..

mattpilott avatar Oct 30 '16 20:10 mattpilott

I don't think it does, this is an older ticket, but any newer ones with similar requests pointed back to it https://github.com/babel/babel/issues/670

subhaze avatar Oct 30 '16 20:10 subhaze

Lame, theres not a way I can do this currently in CK. I can see why it works the way it does however it would make a world of difference to have a more granular control over the way CK concats files. Even if the solution is to set the process config on each file rather than the main. That would be fine.

mattpilott avatar Oct 30 '16 20:10 mattpilott

Sorry @bdkjones i'm reopening as there is no way around this in CK my only option is to revert to a task runner and do all this jazz in terminal which I loathe, deeply.

mattpilott avatar Oct 31 '16 15:10 mattpilott

Hi everyone

Has anyone found a solution to this? I would love to be able to take advantage of transpiling my code in babel while leaving the imports untouched and still included.

Is there a work around for this without involving webpack or browserify? Maybe some setting somewhere to tell codekit which imports or files in the chain not to run through babel?

Thanks!! :)

maxsupera avatar Dec 20 '16 15:12 maxsupera

Yes. I have. It will be in the next update.

Sent from my iPhone

On Dec 20, 2016, at 10:50, HB Woodrose [email protected] wrote:

Hi everyone

Has anyone found a solution to this? I would love to be able to take advantage of transpiling my code in babel while leaving the imports untouched and still included.

Is there a work around for this without involving webpack or browserify?

Thanks!! :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

bdkjones avatar Dec 20 '16 16:12 bdkjones

man, you are so goddamned awesome. i dont understand how you do all of this, but i am eternally grateful :)

maxsupera avatar Dec 20 '16 16:12 maxsupera

Whiskey, mostly.

Sent from my iPhone

On Dec 20, 2016, at 11:27, HB Woodrose [email protected] wrote:

man, you are so goddamned awesome. i dont understand how you do all of this, but i am eternally grateful :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

bdkjones avatar Dec 20 '16 16:12 bdkjones