Comments (7)
@krzksz FYI It doesn't work because select2 lib includes define(
multiple times for example:
define(['jquery'], factory);
S2.requirejs = requirejs;S2.require = require;S2.define = define;
S2.define("almond", function(){});
here's the condition from magepack/lib/bundle.js
else if (!moduleContents.match(/define\s*\(\s*['"]/m)) {
moduleContents = moduleContents.replace(
/define\s*\(/m,
`define('${moduleName}', `
);
}
It will not work because it will catch define("almond"
Not sure how to fix it but maybe you can check if there is no .
before define
in this expression or just search for only first occurance of define
from magepack.
@orthener I discovered when bundling with Magepack the select2 module doesn't get a unique name so once part of the bundle file you get the anonymous mismatched error.
As a quick fix you can manually add a name to the select2.js which will then allow it to work correctly in the bundle, see below.
(function (factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. define('**your_unque_name**', ['jquery'], factory); } else if (typeof module === 'object' && module.exports) {
from magepack.
# magepack.config.js. Autogenerated
module.exports = [
{
url: [],
name: 'product',
modules: {
...
'js/vendor/select2/select2.full.min': 'js/vendor/select2/select2.full.min',
...
}
},
]
# requirejs-config.js
var config = {
map: {
'*': {
select2: 'js/vendor/select2/select2.full.min' // replace default select with full
}
};
In magepack.config.js tried:
'select2': 'js/vendor/select2/select2.full.min',
Same result
from magepack.
Have you applied the "Refactor JavaScript mixins module" patch ?
from magepack.
I'm also seeing the same error with select2. I have the mixins patch applied.
This doesn't occur when bundling with Baler or DevTools/r.js.
from magepack.
Have you applied the "Refactor JavaScript mixins module" patch ?
Yes.
from magepack.
Stumbled upon this as well. Naming the define in the select2 code breaks the developer mode, when magepack is not active though, so we just went with removing it from the magepack bundle which is a fine workaround for the moment for us.
from magepack.
Related Issues (20)
- One big js still creating HOT 4
- How to generate config file before each deployment
- bundlingConfig.forEach is not a function Getting issue HOT 1
- Error javascript after bundling process HOT 10
- Terser Minify-Error: Unexpected token: punc (.) HOT 8
- cms pages allows generate zero items HOT 1
- Module suddenly stopped working HOT 2
- Magento 2.4.5 issues HOT 28
- Issue with JS after update to 2.11.0 HOT 5
- Version 2.11.0 causing error in require.min.js HOT 1
- Issue with JS after update to 2.11.2 HOT 1
- SQL insert issues when reindex is trigger by cron HOT 1
- Vimeo js configs aren't being generated properly HOT 1
- [email protected]: < 18.1.0 is no longer supported HOT 4
- Generate doesn't work with ARM/Graviton server HOT 1
- bundle-common.js and page specific bundle-*.js is loaded 2 times on the page load HOT 5
- "JS_Parse_Error [SyntaxError]: Unterminated string constant" In moment.js During Bundle HOT 1
- Could not find Chrome (ver. 115.0.5790.98) HOT 1
- Bump puppeteer version from ^2.1.1 to latest HOT 1
- Does it makes sense to use magepack for PWA Studio?
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 magepack.