Skip to content
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

mOxie namespace gone? v1.5.3 #171

Open
JohnRSim opened this issue Jun 7, 2017 · 14 comments
Open

mOxie namespace gone? v1.5.3 #171

JohnRSim opened this issue Jun 7, 2017 · 14 comments
Labels

Comments

@JohnRSim
Copy link

JohnRSim commented Jun 7, 2017

Tried to use https://github.com/moxiecode/moxie/blob/master/src/javascript/o.js to bring int he namespace but getting the following error

o.js:23 Uncaught TypeError: Cannot read property 'core' of undefined
at o.js:23

Simple example - also tried shim within config requirejs.

require(['/moxie.dev.js'],function() {
    require(['/o.js'],function() {
        var test2 = mOxie.FileDrop('test');
    });
});

Whats the new approach of using mOxie without plupload?

@JohnRSim
Copy link
Author

JohnRSim commented Jul 7, 2017

Anyone else had this or do I just bring in plupload and moxie can no longer be run standalone?

@jayarjo
Copy link
Contributor

jayarjo commented Jul 8, 2017

You could include those files directly. Or simply use moxie namespace.

Maybe I should make o.js importable. But currently it is not compatible with non-global moxie namespace.

@JohnRSim
Copy link
Author

JohnRSim commented Jul 8, 2017

Let me try moxie I thought I had tried that and it hadn't worked either. Without the plupload scripts

@jayarjo
Copy link
Contributor

jayarjo commented Jul 8, 2017

moxie namespace is structured differently, so to access FileDrop for example, use absolute name - moxie.file.FileDrop.

@JohnRSim
Copy link
Author

JohnRSim commented Jul 9, 2017

@jayarjo if I do the following I'm getting undefined for moxie as well.
Without importing the plupload libs.

require(['/moxie.min.js'],function() {
    console.log(moxie); //undefined
});
require(['/moxie.min.js'],function(moxie) {
    console.log(moxie); //undefined
});

The moxie lib is being imported.
image

I don't see any moxie in window namespace either.

@JohnRSim
Copy link
Author

JohnRSim commented Jul 9, 2017

if I just add the following in a blank html template

<script src="lib/moxie/js/moxie.min.js"></script> 

Without using require within a html file then moxie namespace is available.

  • is require() no longer supported with moxie.. it was in an old version I was using v1.2.1

Thanks
J.

@jayarjo
Copy link
Contributor

jayarjo commented Jul 9, 2017

You do not need to get fancy there. Simple:

require(['moxie'], function(moxie) {
    console.log(moxie);
});

should do the thing.

Or even:

import moxie from 'moxie';

if your environment is ready.

@JohnRSim
Copy link
Author

JohnRSim commented Jul 9, 2017

That's what I thought but if I strip everything right down and do this as a basic example/test -
moxie is still undefined - I can see it is loaded within the head tags.

//this is shown in the html head after the page loads -
<script type="text/javascript" charset="utf-8" async="" data-requirecontext="_" data-requiremodule="lib/moxie/js/moxie.min.js" src="lib/moxie/js/moxie.min.js"></script>

This is the test I'm using stripped down:

<!doctype html>
<html class="no-js" lang="">
<head>
	<meta charset="utf-8">
	<meta http-equiv="x-ua-compatible" content="ie=edge">
	<title></title>
</head>
<body>

	<script src="../../../lib/requirejs/require.min.js"></script>
	<script>
	require(['lib/moxie/js/moxie.min.js'], function(moxie) {
	    console.log(moxie);
	});
	</script>
</body>
</html>

window.moxie also does not exist?
If I try to search for it in the console.

@jayarjo
Copy link
Contributor

jayarjo commented Jul 9, 2017

Sorry I had an impression that you were using Webpack. I've never used RequireJS, so can't help you there. It might be that mOxie is not even compatible with it, unless it auto-magically follows the same conventions.

window.moxie will be available if you include moxie directly in a non-AMD environment.

@jayarjo
Copy link
Contributor

jayarjo commented Jul 9, 2017

I think what you were lacking was proper config. This worked fine for example:

<!doctype html>
<html class="no-js" lang="">
<head>
	<meta charset="utf-8">
	<meta http-equiv="x-ua-compatible" content="ie=edge">
	<title></title>
</head>
<body>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.3/require.min.js"></script>
    <script>
        require.config({
            baseUrl: "lib",
            paths: {
                "moxie": "mOxie/bin/js/moxie.min"
            }
        });

        require(['moxie'], function(moxie) {
            console.log(moxie);
        });
	</script>
</body>
</html>

Be sure to adjust config to your local paths.

@JohnRSim
Copy link
Author

JohnRSim commented Jul 9, 2017

ahh ;) - it used to work - as I used it with requirejs in v1.2.1 - but when I upgraded to latest release it broke.

@jayarjo
Copy link
Contributor

jayarjo commented Jul 9, 2017

It might be that RequireJS was simply loading the script. mOxie, just as plupload were not properly encapsulated, so should have leaked namespaces to global environment. We had multiple complaints about this, so we "fixed" it.

Try the config above, it worked for me.

@JohnRSim
Copy link
Author

JohnRSim commented Jul 9, 2017

Yup - the above worked for me... Strange..
I was playing around if I use the name to load it in it works as you show - but if I define the path in require it doesn't ie.

ie Failed path entry

require(['moxie/js/moxie.min'], function(moxie) {
    console.log(moxie);
});

Worked - config name entry

require(['moxie'], function(moxie) {
    console.log(moxie);
});

@jayarjo
Copy link
Contributor

jayarjo commented Jul 9, 2017

Internally the module is defined as moxie, so fancy stuff like absolute path will fail. That might explain this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants