-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transform dynamic imports to static imports #59
Comments
Hello @jankapunkt , Don't think it requires an additional PR to the codebase. And this package pending general update, hope to put my hands on it soon. Open for further discussion in case if I'm wrong |
Thank you for the fast response @dr-dimitru I am using this package to build a demo application for one of my client-side packages that runs on github.io but the problem is, that the package uses dynamic imports to reduce initial bundle size. I tried to introduce static imports that are only included when I set a flag in Meteor.settings but then the build of the package always seems to use static imports. I will try to figure out how to code-split a dynamic and a static version of the same package and will update some of the README here when I found (or not found) a solution. |
- ES6; - Overall codebase refactoring and linting; - Remove spinner, `simple-spinner` dependency, and `-hide, --hideSpinner` command line options; - Support for modern (ES6) and legacy (ES5) builds (legacy build is used by default); - Support for Meteor's `<meteor-bundled-js/>` and `<meteor-bundled-css/>`; - Support for `body.html` and `blaze-html-templates` (see updated readme); - Support for `{{url-to-meteor-bundled-css}}` placeholder, which can be used in `<link rel="preload">`; - `--usebuild` option now accepts `<path>` to the build; - Update NPM dependencies; - Closing: #53, #40; - Solving: #61, #57, #55, #42; - Taking into account: #59, #35;
@jankapunkt do you think it would possible to pull all dynamic imports as static files, and rewrite Can't find how meteor generates assets for static import 🤔 |
I haven't figured it out, too. However, we may have a Chance to override the dynamic import to use static require under the hood, since it is not the native esmodule implementation. |
## v1.0 - Update codebase to ES6; - Overall codebase refactoring and linting; - __Breaking__: Remove spinner, `simple-spinner` dependency, and `-hide, --hideSpinner` command line options; - Support for modern (ES6) and legacy (ES5) builds (legacy build is used by default); - Support for Meteor's `<meteor-bundled-js/>` and `<meteor-bundled-css/>`; - Support for `body.html` and `blaze-html-templates` (see updated readme); - Support for `{{url-to-meteor-bundled-css}}` placeholder, which can be used in `<link rel="preload">`; - __Breaking__: `--usebuild` option now accepts `<path>` to the build; - Update NPM dependencies; - Use `fs-extra` module to move files around; - Check that `Meteor` and `Meteor.disconnect` exist in global space; - If `--url` option is not passed create dummy `sockjs/info` to avoid connect DDP exceptions; - Closing: #53, #40; - Solving: #61, #57, #55, #42, #18; - Taking into account: #59, #35;
Have an idea for case when building Client only for modern browsers link script with To this moment all my tests were throwing errors... and yes, it requires Server, while this package focus on Client only solution. I hiope this comment would inspire someone for a solution or spark discussion. |
Hi @dr-dimitru , Just wanted to ask, will this package support Dynamic Imports? If yes, then can you share by when we will be able to use it in our projects? |
Hello @technicalbirdVayuz ,
|
Can you please share an example of this?
|
How does it relate to Dynamic imports? Can you please explain |
@technicalbirdVayuz dynamic |
Hi, @dr-dimitru Can you share a small sample please? Not sure, where to put code for this |
@technicalbirdVayuz it's just an example. No actual changes in your codebase required. By default your app will connect to a server address passed into To test this locally:
To be quite honest — I'm not sure about if no.3 going to work without locally running |
I tried the and steps, it worked. First of all, I have not used DDP connection as mentioned here but without this its working fine [Instead if I add that code, then I got DDP is not defined] there is one error also, noe from where It is coming from Also, My idea of using this packageas as an micro Service but using it this way will make it highly dependent on the server, would be great if we can use it as a stand-alone build. |
& Also, If we have to run this way then why should we create a client build. In any case, We need to run the server & server ideally has the client code too. Please correct me if I am wrong @dr-dimitru |
This isn't possible due to the way dynamic imports implemented. At the moment it serves compiled pieces of code in batches meaning multiple packages and files are served in the single request. If there will be a way to request packages one-by-one, then we can place all code-pieces as static files under public directory. Simply replacing dynamic imports with static imports during the building phase won't work either as "dynamic" pieces of code won't be a part of "bundle" |
You can place client build into CDN, or have many servers serving static files and one handling server-part |
This means server return HTML instead of JSON, I'd start with inspecting "Network" tab |
Thanks for the quick response. Just want to ask one more thing, will it be considered as a microservice if we use it this way as it is not loosely coupled now. |
Nope. Microservice usually focused on performing single task, but doing it very well in the most efficient way. Nowadays this term has broad meaning, so some folks can call it microservice. I'd just call it backend and static servers |
Ok. Do you have any references where we can use Meteor as a Micro Service? |
@technicalbirdVayuz Meteor is great for:
On the server it's just Node.js, so I'd suggest using pure "vanilla" Node.js to build microservice |
@dr-dimitru a little bit off-topic but:
I agree hre, unless you want some of the Meteor Magic, like Mongo Integration, DDP (to connect with other Meteor apps) or Accounts, then I suggest to watch my presentation on Microservices with Meteor |
@jankapunkt great mention. It seems to me that it only applicable if you're building ecosystem/infrastructure on top of Meteor — then it makes sense to keep micro services on top of Meteor. In our case we always end up building vanilla Node.js micro services for efficiency and smallest footprint possible. Data between micro services usually exchanged via Database (MongoDB in our case). Good references can be found at microservices.io |
The
dynamic-import
package does not work with a client-only app, so we need to bundle all imports while building statically.A similar approach is done by
bundle-visualizer
. I could provide a PR if there is some alive-ping.The text was updated successfully, but these errors were encountered: