Comments (9)
Thank you @enuchi ,
It's a private repository of my company so I can't share it.
I will check those webpack links. I will close this issue now. Seems that it's solved
from react-google-apps-script.
Hey @piavgh not sure why that's happening. Is it only on the html files or are you also seeing large files on the transpiled server code?
from react-google-apps-script.
Hi @piavgh, following up on your large bundle comment. I am seeing the same issue now, and it looks like it is due to the output: { beautify: true }
setting for UglifyJs in the webpack config. This setting is useful for server side code, so that for any errors that are thrown you at least know which function threw the error. If it's fully minified, you will get an unhelpful function name.
However, it is probably not needed in the shared, ie client + server webpack settings -- for client side code it is optimal to minify react bundles, as you are more likely to have large bundles, for example react
and other client side libraries. I will update the webpack settings so that the beautify: true
setting is only applied to the server-side code. This should hopefully fix your issue.
Note that I think the browser may still freeze when you open the script in script.google.com if you have large code base or many packages but let me know.
from react-google-apps-script.
@enuchi : Hi, thank you for your information.
In my case, only .html files are large and can't be opened on script.google.com.
My server-side code is normal and can be opened without any problem.
The reason that my bundles are 2-3 MB each file is because I'm using Ant design and Firebase, which are huge libraries:
ant-design/ant-design#12011
firebase/firebase-js-sdk#332
I think if I don't use these libraries, the bundles are just 500KB+ maybe.
from react-google-apps-script.
hi @piavgh, do you mind setting beautify: false
in this line in the webpack file, then run npm run build
and see how big the bundles are?
from react-google-apps-script.
@enuchi : I've just tested it.
The bundle size is reduced from 2.8MB to 2.2MB.
from react-google-apps-script.
Got it. So I'm guessing it's mainly the large libraries you pointed out above. If you have a repo I can clone and test out I'm happy to look at it. You may also want to look into code splitting and defining chunks for these large libraries.
code splitting
lazy loading
split chunks docs
I'll update the client-side webpack config to beautify: false
at some point soon, since that also reduced the size for client bundles for me.
from react-google-apps-script.
Have been thinking about this more @piavgh and think I have a better solution. I took my bundle down from around 500kb to 60kb, and now the html pages don't crash my browser in the Google Apps Script IDE.
Google's HTML Dialogs don't allow importing separate .js files in your html file, for instance you can't do: <script src="./bundle.js">
like with normal websites. My current approach is to 'inline' the entire code bundle into one html file. Code splitting won't help because that will just try to make bundle1.js, bundle2.js etc, which will then get inlined, and the overall size will be the same.
An alternative approach is to load every external library from a CDN. This will help with your package size and hopefully do some caching for you for faster loading. There is a great webpack plugin I found that will do this for you called dynamic-cdn-webpack-plugin
. This will scan your imports and create script tags that load all your external libraries, for instance react
, react-dom
, and in your case hopefully ant-design
and firebase
get loaded from cdn.
Try the following:
npm install --save-dev dynamic-cdn-webpack-plugin module-to-cdn
- in webpack.config.js add the following import, and modify clientConfigs
// at top of file
const DynamicCdnWebpackPlugin = require('dynamic-cdn-webpack-plugin');
...
// modify clientConfigs to add the new plugin, and change inlineSource
const clientConfigs = clientEntrypoints.map(clientEntrypoint => {
return {
...clientConfig,
name: clientEntrypoint.name,
entry: clientEntrypoint.entry,
plugins: [
new HtmlWebpackPlugin({
template: htmlTemplate,
filename: clientEntrypoint.filename,
inlineSource: '^[^(//)]+.(js|css)$', // 1. change this line to embed all js and css inline, but exclude packages with '//' to allow dynamic cdn insertion of external libraries
}),
htmlWebpackInlineSourcePlugin,
webpackCleanPlugin,
new DynamicCdnWebpackPlugin(), // 2. add this line here
],
};
});
- Also move the
optimization
object fromsharedConfig
toserverConfig
withbeautify: true
as discussed above so that only the server code is beautified.
Let me know if you have success!
from react-google-apps-script.
Should be fixed by #25
from react-google-apps-script.
Related Issues (20)
- Can we migrate to vite? HOT 4
- White (blank) sidebar in Chrome when using Station wallet Chrome extension HOT 12
- How to use shadcn/ui HOT 1
- Issue: app is not loaded when I deploy, but does work with HMR HOT 2
- I want to use fast refresh without https
- How to deploy a google workspace addon using this? HOT 6
- Is it possible to pass initial state to React root component? HOT 3
- Uncaught ReferenceError: react is not defined HOT 1
- Typescript support for custom functions HOT 14
- Seeing "Running script" with "Cancel" and "Dismiss" instead of "Working" when executing opening the sidebar HOT 2
- Support for NextJs HOT 4
- Uncaught ReferenceError: emotionReact is not defined at 9291 (userCodeAppPanel:2:53729) HOT 5
- JSdocs Autocomplete not working as expected HOT 9
- ReferenceError: TextEncoder is not defined : how to diagnose a solution HOT 3
- TypeScript support for TableCell.setBold() TableCell.setFontSize() HOT 1
- Solution for webapp react-router sync with google.script.history (Client-side API) HOT 3
- How to expose an Appscript ServerFunction to the user for attaching as a script? HOT 3
- How to create custom functions in V3 version? HOT 5
- [Q] Any breaking change while migrating from V2 webpack to V3 vite? HOT 2
- Close dialog in Development Mode using google.script.host.close() HOT 1
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 react-google-apps-script.