amarcruz / jsccify Goto Github PK
View Code? Open in Web Editor NEWBrowserify transform for contitional comments and variable replacement using jscc
License: MIT License
Browserify transform for contitional comments and variable replacement using jscc
License: MIT License
I found a problem trying to put a debug logging function in a separate module using ES6 modules:
Source "main.js":
//#if _DEBUG
//#set _LOG 'debugout'
import {$_LOG} from './mymodule'
//#else
//#set _LOG '//'
//#endif
$_LOG('Oops!')
Source "mymodule.js":
/*#if _DEBUG
export function debugout (s) {
console.log(s)
}
//#elif 0 // */
export const $_LOG = null
//#endif
In all other submodules (imported from main.js) I could then shorten the boilerplate to the following since _LOG has already been set through main.js. I think there's no easy solution to get rid of the if condition since it is part of the import clause:
//#if _DEBUG
import {$_LOG} from './mymodule'
//#endif
After running browserify without jsccify:
mymodule.$_LOG('Oops!');
After running browserify with jsccify and _DEBUG = 0:
mymodule.//('Oops!');
This is the problem. It seems to apply jscc a bit too late.
After running browserify with jsccify and _DEBUG = 1:
mymodule.debugout('Oops!');
But now it is complaining that debugout is not defined in the other module which probably means that some processing order is not right.
Note that the same is working with the rollup plugin.
I use -t jsccify -p tsify
as browserify options. The tsify
is for TypeScript transpilation but I guess the same would happen with any kind of transpilation.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.