Comments (6)
Alas that's unavoidable in this case. You can use globals, or bundle all your libs in a single bundle for example.
In here the polyfill, core and run-main are 3 separate bundles each containing a bunch of stuff.
from txiki.js.
Understood thanks, you've been very helpful.
from txiki.js.
Then you convert the resulting
polyfills.js
file intopolyfills.o
code usingqjsc
.
Not quite, this generates a polyfills.c file, it's C source code, basically an array with the JS bytecode.
It's included in the build here:
Line 87 in 6439949
So it gets compiled with the rest of the binary.
from txiki.js.
I was thinking that the -c
flag is needed to convert to C code.
-c
Only output bytecode in a C file. The default is to output an executable file.
https://bellard.org/quickjs/quickjs.html#qjsc-compiler
from txiki.js.
I was thinking that the
-c
flag is needed to convert to C code.
Correct, it outputs a C file. You can see it here: https://github.com/saghul/txiki.js/blob/master/src/bundles/c/core/run-main.c
from txiki.js.
When I convert a JS file to C, all its dependencies are also included in C. How did you avoid this?
I have two libraries:
lib-A.js
lib-B.js
lib-A.js
needs lib-B.js
.
When I compile, the lib-A.c
file contains both its own code and lib-B.js
, while lib-B.c
contains only its own code.
It's actually normal, but it's causing problems with it.
I can avoid this like this: I create index.js
file and import it into two files so I have a single module.c
file that contains both lib-A.js
codes and lib-B.js
codes.
The minus side of this is that index.js codes that will not be used will be added and the resulting C file will be large.
from txiki.js.
Related Issues (20)
- Windows build - info/discussion HOT 7
- Windows: Date() ignores timezome HOT 2
- Add top level await support to REPL HOT 1
- Consolidate EOF marker
- Implement history support in the REPL
- Implement localStorage and sessionStorage HOT 1
- Build problems on OpenBSD HOT 5
- Add typescript declaration file ? HOT 2
- Add mbedtls to support https & crypto HOT 12
- fetch() from browser net::ERR_INVALID_HTTP_RESPONSE when testing tjs.listen() HOT 5
- utils.js is not found in build HOT 2
- v23.1.0 has unpredictable segfaults when running invalid JS files HOT 3
- Can not build in MAC HOT 4
- Support Uint32Array, other TypedArray's and ArrayBuffer parameter for stdin.read() (StdioInputStream)) HOT 8
- Add timeout for http imports
- Build problems on macOS 11.2.3 HOT 5
- Could this be used on an e.g. Pico Pi? HOT 2
- support indexedDB implement HOT 7
- FFI does not support complex structures
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 txiki.js.