Comments (18)
Turning caching on greatly improved re-building times:
let config = {
homeDir: "js",
cache: true,
plugins: [
fsbx.BabelPlugin({
config: {
sourceMaps: true,
presets: ["es2015", "react"]
}
})
]
}
let config1 = Object.assign({}, config, { outFile: "_build/out1.js" })
let fuseBox1 = FuseBox.init(config1);
fuseBox1.bundle(">app2/react.jsx +react +react-dom", false);
let config2 = Object.assign({}, config, { outFile: "_build/out2.js" })
let fuseBox2 = FuseBox.init(config2);
fuseBox2.bundle(">app2/react.jsx +react +react-dom", false);
But how now to make 3rd-party separate "vendor" file?
Just create 3rd out file like above with some "package" config magic and all "requires" will magically work?
from fuse-box.
Finally got it working with the following:
const fsbx = require("fuse-box");
const FuseBox = fsbx.FuseBox;
let config = {
homeDir: "js",
cache: true,
plugins: [
fsbx.BabelPlugin({
config: {
sourceMaps: true,
presets: ["es2015", "react"]
}
})
]
}
let config1 = Object.assign({}, config, { outFile: "_build/out1.js" })
let fuseBox1 = FuseBox.init(config1);
fuseBox1.bundle(">app2/react.jsx -react -react-dom", false);
let config2 = Object.assign({}, config, { outFile: "_build/out2.js" })
let fuseBox2 = FuseBox.init(config2);
fuseBox2.bundle(">app2/react.jsx -react -react-dom", false);
let config3 = Object.assign({}, config, { outFile: "_build/vendor.js" })
let fuseBox3 = FuseBox.init(config3);
fuseBox3.bundle("+react +react-dom", false);
And with following HTML:
<script type="text/javascript" charset="utf-8" src="vendor.js"></script>
<script type="text/javascript" charset="utf-8" src="out1.js"></script>
But it seems like boilerplate (((
I guess there is need in some plugin like webpack's "CommonsChunkPlugin" that could handle such scenario and automatically extracts all commons into separate output bundle.
I could try to hack on this, but it seems FuseBox plugins has no API to create/specify additional output files :(
from fuse-box.
You can bundle anything without an entry point
http://fuse-box.org/#arithmetic-instructions
In essence, entry point is not required
from fuse-box.
Thanks for quick reply :)
I guess there is a lack in documentation.
My goal is not to exclude an entry point, but to have several "bundles" as output at once.
The config above defines that I after executing I want to have three output bundles:
- "main.js" - one SPA application.
- "admin.js" - second independent SPA application
- "vendor.js" - common third-party code
Where "main" and "admin" - are separate entry points.
There's still not clear how to achieve this scenario from provided docs.
It could be fine to see some example how to do it.
from fuse-box.
Hi! I am on my phone now, but you can try using FuseBox.import() your entire bundle is available via that API
from fuse-box.
You can bundle everything using ./.** and then use
http://fuse-box.org/#import This API to call any files Within that bundle.
Or you can have 2 bundles (they will share the scope)
FuseBox provides much more flexible API than webpack :) read up :)
from fuse-box.
I'm experimenting with all it now, but without much success yet.
from fuse-box.
Use globbing to make sure it's all there, then try window.FuseBox.import
from fuse-box.
Try where? In build script or at the client side entry point file?
I"m still don't get :( If I omitting "outFile" in the config, then nothing is creating at all...
from fuse-box.
Again: I need two files as output, not single one.
from fuse-box.
You can access any file in a bundle (after it has been bundled) via FuseBox.import
(In browser and on server). Include it as a script tag (your bundle) open developer console and try using FuseBox.import (runtime)
from fuse-box.
As for now, I cann't see other way than simple calling FuseBox twice:
let fuseBox = FuseBox.init({
homeDir: "js",
cache: false,
outFile: "_build/out1.js",
...
});
fuseBox.bundle(">app1/react.jsx ...", false);
let fuseBox = FuseBox.init({
homeDir: "js",
cache: false,
outFile: "_build/out2.js",
...
});
fuseBox.bundle(">app2/react.jsx ...", false);
from fuse-box.
If you need 2 files use 2 instances (you can share your config)
from fuse-box.
That's what I guessed from beginning :(
I end up with this:
const fsbx = require("fuse-box");
const FuseBox = fsbx.FuseBox;
let config = {
homeDir: "js",
cache: false,
plugins: [
fsbx.BabelPlugin({
config: {
sourceMaps: true,
presets: ["es2015", "react"]
}
})
]
}
let config1 = Object.assign({}, config, { outFile: "_build/out1.js" })
let fuseBox1 = FuseBox.init(config1);
fuseBox1.bundle(">app2/react.jsx -react -react-dom", false);
let config2 = Object.assign({}, config, { outFile: "_build/out2.js" })
let fuseBox2 = FuseBox.init(config2);
fuseBox2.bundle(">app2/react.jsx -react -react-dom", false);
Problems:
-
How to make third output file with all "vendor" libs? (react, react-dom, react-router etc)
So all imports should works in above main bundles? -
If there's common code it will be duplicated and parsed twice :(
I guess FuseBox should support such scenario, that is provided by webpack out-of-the-box.
Seems this is not so uncommon case.
from fuse-box.
yes, currently there is only one source, but we can and will improve it :)
from fuse-box.
from fuse-box.
Thanks. Will follow it. It seems promising.
from fuse-box.
Implemented in 1.4.1
from fuse-box.
Related Issues (20)
- pluginConsolidate not working HOT 1
- "manifest" RunProps are ignored
- css background-image url with @ in path is not managed as resource HOT 7
- incorrect removal of parentheses in `(-(--t))`
- fuse-box@4 vue2.x.x .vue files support
- Log output indicates that `'@'` characters in file paths are changed into `'undefined'`
- Incorrect processing of awaited brackets
- ESM output support HOT 3
- Node_modules folder debug HOT 1
- node-sass is deprecated HOT 2
- Sass, and non-existent .css.map files HOT 2
- Failed to resolve %23clip in a css file HOT 4
- Transpilation Error with fuse-box 4.0.0 (or maybe I'm simply blind) HOT 1
- 4.0.0 Dependency bundled as two separate instances in production build
- `rootDir` does not exist in type IPublicOutputConfig
- Cannot find module: fuse-box/sparky HOT 7
- Is it possible to share an assets folder between two projects?
- Support Angular 13
- TypeError: Cannot read property 'filename' of undefined HOT 4
- Archive project
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 fuse-box.