Comments (3)
This must works (I don't test it):
Read the object at compile time and send it to jscc in the values property of the options.
import thing from '../my-thing.js';
const processedCode = jscc(code, {
values: { _THING: thing }
// now `thing` is visible at compile-time
})
If you are using a plugin, for example w/rollup, do that in your rollup.config.js
from jscc.
Yes, that was what I was looking for; and it works, thanks!
Note: comment should maybe say "now _THING
is visible..."
from jscc.
@smth , you are trying to get a runtime value with a compile-time tool.
I mean, jscc runs in its own space at compile time and does not know anything about the values of variables in the code it processes.
It uses JavaScript to decide which code block to include or exclude, or which text to replace in the code, but treats these code as simple text, does not evaluate it.
This behavior is similar to that of the C preprocessor, but it may be a strange concept for the JS world. I will put a note in the Readme about it, when have the time :)
Closing the issue now, thanks for your feedback.
from jscc.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jscc.