I am trying to reduce primary bundle size by using ag-grid-community and ag-grid-enterprise from CDN
I've added the following lines to the HTML
<script crossorigin src="https://unpkg.com/ag-grid-community#25.3.0/dist/ag-grid-community.min.noStyle.js"></script>
<script crossorigin src="https://unpkg.com/ag-grid-enterprise#25.3.0/dist/ag-grid-enterprise.min.noStyle.js"></script>
and the following lines to the webpack
externals: {
'react': 'React',
'react-dom': 'ReactDOM',
'react-router-dom': 'ReactRouterDOM',
'ag-grid-enterprise': 'ag-grid-enterprise',
'ag-grid-community': 'ag-grid-community'
}
Now I am getting the following error
Uncaught TypeError: can't access property "ColDefUtil", AgGrid is undefined
js agGridColumn.js:58
Webpack 32
the root cause of this error - the following line in ag-grid-react
var AgGrid = require("ag-grid-community");
Related
Source Code
The error message is
Uncaught ReferenceError: exports is not defined
The compiled code contains Object.defineProperty(exports,"__esModule",{value:!0})
Found a solution by google: <script> var exports = {}; </script>
but Cannot find module './Index.b211c312.js'
│ index.html
└─_assets
Index.b211c312.js
index.fa062449.js
style.032a3e7d.css
in index.html
<script type="module" src="./_assets/index.fa062449.js"></script>
in index.fa062449.js
require("./Index.b211c312.js")
How to solve this problem?
Update electron-vue-vite to the latest version, there is a fix!
https://github.com/electron-vite/vite-plugin-electron/issues/6#issuecomment-1144833465
Trying to get a (what should be) simple module to work: metisMenu
However, unfortunately I'm failing in doing so, apparently something in my Webpacker setup because when loading my page I get the error: Uncaught TypeError: $(...).metisMenu is not a function
There is an issue in loading the module in application.js. The module is being loaded in vendor/assets/javascripts/app.js
I have jQuery correctly installed
the following snippet into the head section makes it work (but this is without the use of Webpaker):
<script src="https://cdn.jsdelivr.net/npm/jquery"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://unpkg.com/metismenu"></script>
.
I've created a github branch. Please help! https://github.com/henkjanwils/metisMenu-error
When trying to save the PDF file, the following stack trace occurs and the file is not downloaded:
TypeError: Object expected
at API.save (http://localhost:8080/applications/lib/jspdf/jspdf.debug.js:3648:11)
at Anonymous function (http://localhost:8080/applications/js/<my_custom_js_file>.js:288:12)
at Anonymous function (http://localhost:8080/applications/lib/angular-1.5.8/angular.min.js:158:482)
at e (http://localhost:8080/applications/lib/angular-1.5.8/angular.min.js:45:442)
at Anonymous function (http://localhost:8080/applications/lib/angular-1.5.8/angular.min.js:48:300)
Also tried with a simple example and had the same results:
var doc = new jsPDF();
doc.text("hello", 20, 20);
doc.save("table.pdf");
IE does not support native Promise. Therefore, the initialization script fails at line 12016 of Version 1.5.3:
SCRIPT5009: 'Promise' is undefined
jspdf.debug.js (12016,5)
Afterwards, the script is no longer initializing the required context.
A fix should be a 3rd party promise library - I have solved it by including the following resources before including jspdf.debug.js:
<script type="text/javascript" src="/applications/lib/ie-promise/es6-promise.js"></script>
<script type="text/javascript" src="/applications/lib/ie-promise/es6-promise#4/dist/es6-promise.auto.js"></script>
Following the tutorial here, I have managed to get webpack doing my bundling for me, and it is working for pre-rendering on the server side, e.g.:
#Html.React("Components.myComponent",
New With {
.initialData = Nothing
})
#Html.ReactInitJavaScript()
This is correctly displaying my component in the browser, but as soon as the client takes over I get the error 'ReactDOM' is undefined
I have installed the react-dom using npm install react-dom --save-dev
I have tried to require the ReactDOM, first in the .jsx file containing my component, then in the client.js file that webpack is building from:
//myComponent.jsx
var React = require('react');
var ReactDOM = require('react-dom');
or
//client.js
var ReactDOM = require('react-dom');
var Components = require('expose?Components!./src');
But I am still getting the same error.
If I add the react and react-dom scripts directly above my webpack compiled client javascript, then the problem goes away:
//index.html
<script src="https://www.facebook.com/react-0.14.0.min.js"></script>
<script src="https://www.facebook.com//react-dom-0.14.0.min.js"></script>
<script src="~/Scripts/webpack/build/client.bundle.js"></script>
So how can I get webpack to properly include these scripts in the client bundle?
EDIT
I did have the following externals in my webpack.config.js, but removing them doesn't seem to make any difference.
externals: {
// Use external version of React (from CDN for client-side, or
// bundled with ReactJS.NET for server-side)
react: 'React'
}
I guess, externals are there so you can use CDN based scripts, so maybe I am overthinking this one and should just leave the CDN based react scripts in my view?
You should expose react-dom globally in your client.js, so it will be available in browser in ReactDOM variable to render client-side:
require("expose?ReactDOM!react-dom");
How should I include jquery.mobile.js in my project so that I can use it with RequireJS.
When I add jquery.mobile.js in my project I start getting following error.
Uncaught Error: Mismatched anonymous define() module: function ( $ ) {
factory( $, root, doc );
return $.mobile;
}
I also followed this post.
Separating jQuery Mobile (1.1.0) from AMD (RequireJS)
Here is a working example. It includes Requirejs, jQueryMobile, Backbone, and Marinonette.
In the index.html file, you need to specify the main module for requirejs to load.
<script type="text/javascript" data-main="js/main" src="js/libs/require-2.1.2.min.js"></script>
In this example, the main module is under "js/main.js"
Inside, main.js, you specify the require.config and use define to load your modules.