Comments (17)
@daviddelusenet Will see if I can set something up this week.
from conditioner.
Hi @daviddelusenet, I'll see if I can setup an example somewhere in the coming week.
from conditioner.
@rikschennink Thanks for your help! I got it working for now, but that is because my old colleague Pascal Strijbos made a custom version of the conditioner.js
. If I use that version, my setup just works. If I use the latest version you made, I get the following error:
Uncaught Error: Cannot find module 'views/ImageUpload'.
This is how my folder structure looks:
- javascript
- conditioner
- conditioner.js
- utils
- monitors
- views
- ImageUpload.js
- app.js
- conditioner
In app.js
I've the following code:
'use strict';
document.addEventListener('DOMContentLoaded', function () {
conditioner.init();
}, false);
Then I have a Image.twig
file where you can find the following line:
<div class="form-component" data-module="views/ImageUpload" data-options='{"url": "http://httpbin.org/post"}'>
And last but not least, this is the code in the ImageUpload.js
file:
'use strict';
module.exports = function (element, options) {
this.el = element;
this.options = options;
this.init();
};
module.exports.prototype = {
init: function () {}
// More functions here
};
Am I right assuming the data-module
path should be a relative path from app.js
? And maybe you see the mistake(s) I'm making based on my code.. Thanks in advance.
from conditioner.
In my experience this is correct. app.js
is the starting point and other modules are loaded relative to the location of that file. But that's based on my experience with SystemJS and RequireJS so I'm not sure that holds true for WebPack.
from conditioner.
I think the problem has to do with the minification of my app.js
. App.js
gets compiled to app.min.js
with webpack and placed in /static/js/app.min.js
.
Including it like this require('./views/ImageUpload')
and compiling with webpack adds the code to app.min.js
but I still get the same error as before.
When I try to point the the module like this
Conditioner.init({
'modules':{
'./views/ImageUpload':'ImageUpload'
}
});
I get the following error: conditioner.js:2410 Uncaught ReferenceError: requirejs is not defined
.
How do I require my ImageUpload.js
in this app.min.js
so that Conditioner can find it?
from conditioner.
Sorry for the delay in my responses, I'm super busy at the moment, situation should improve in the coming weeks.
I think you're on the right track with the modules bit (adding shortcuts). But I would try to define these in WebPack. By default conditioner loads modules using RequireJS so when passing these modules settings it passes the configuration along to requirejs.config().
It's possible to change the interaction with the module loader using the loader
property in the setOptions (or init) method object. http://conditionerjs.com/docs/#conditioner-setoptions
from conditioner.
@rikschennink thanks for your response. I figured out why Conditioner doesn't work for me: my modules are written using the CommonJS syntax!
Are there any plans in the near future for adding CommonJS support?
from conditioner.
To be loaded I in this case think they need to be converted to AMD based modules. Conditioner uses the load() method and passes the value of the data-module attribute (by default it then checks if RequireJS is available to load the module using the module path).
So you can either expose the modules on the global scope or use the attribute value in some other way to get to your modules. They need to be available somehow.
from conditioner.
@rikschennink I've converted my modules to AMD based modules but still can't get it working. There's no example to find anywhere how to use requirejs in combination with webpack. Also there's no example of how to include these AMD modules to webpack that conditioner can find them.
Can you please make an example which uses webpack and conditioner?
from conditioner.
Cool, thanks in advance!
from conditioner.
Would like to support anything but so I'm looking into setting things up differently but not sure yet how.
Compiling the modules to AMD should work though.
On 19 Oct 2016, 13:29 +0200, David de Lusenet [email protected], wrote:
@rikschennink (https://github.com/rikschennink) thanks for your response. I figured out why Conditioner doesn't work for me: my modules are written using the CommonJS syntax!
Are there any plans in the near future for adding CommonJS support?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub (#98 (comment)), or mute the thread (https://github.com/notifications/unsubscribe-auth/ABFIH0tX8YcPqp7zqEhO9YHT21tzVzDGks5q1f8ugaJpZM4KQ_UI).
from conditioner.
@daviddelusenet I've setup this repo, I'm no Webpack expert but it seems to function correctly.
https://github.com/rikschennink/conditioner-boilerplate-webpack
from conditioner.
I also love to see webpack support, i've checked out your boilerplate and played around with it. It works when loading modules on the fly. Only i'm getting errors when using a media condition. I've opened a ticket in your conditioner-boilerplate-webpack repo -> rikschennink/conditioner-boilerplate-webpack#1
from conditioner.
I've updated the WebPack example repo to fix the monitor loading errors.
from conditioner.
Hi Rik,
I just checked out your boilerplate example. It works with webpack version 1.13.3 but fails with webpack 2.4.1. Could you please update the example so it works with the latest webpack release?
Thanks!
from conditioner.
Will look into it as soon as possible.
from conditioner.
Conditioner 2 webpack example can be found here:
https://github.com/rikschennink/conditioner-boilerplate-webpack
Note that the API has completely changed so it's not compatible with Conditioner v1.
from conditioner.
Related Issues (20)
- Example for loading different multiple modules on a single node HOT 2
- Loading AMD module with webpack HOT 1
- Mounting class declarations HOT 13
- How to get exported value from module? HOT 2
- .getModule() and .getModules() doesn't include a search on the target node HOT 3
- .sync() doesn't publish a load event when all modules that are available are also loaded HOT 3
- Look into running condition parsing (or other non ui code) in webworkers HOT 1
- optimize parsing of single monitor conditions HOT 1
- Have execute method return a promise? HOT 1
- Add version number in minified version HOT 3
- Media monitor and <=IE9 HOT 7
- Event Monitor
- Support for SystemJS? HOT 2
- 'unload' handler is not called HOT 5
- ".is" clean up HOT 1
- ".on" cleanup HOT 1
- JSON check in _getModuleControllersByElement() fails due to re-use of RegExp instance with global flag HOT 1
- Value of data-initialized is incorrect after calling Condtioner.load() on a node with active modules
- bower version is 1.2.0 instead of 1.2.2 HOT 2
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 conditioner.