You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current define wrapper in JSONIX blocks usage in webpack2, I wonder if it's time to get rid of this?
/*if (typeof define !== 'function') {^M
// Load the define function via amdefine^M
var define = require('amdefine')(module);^M
// If we're not in browser^M
if (typeof window === 'undefined')^M
{^M
// Require xmldom, xmlhttprequest and fs^M
define(["xmldom", "xmlhttprequest", "fs"], _jsonix_factory);^M
}^M
else^M
{^M
// We're probably in browser, maybe browserify^M
// Do not require xmldom, xmlhttprequest as they'r provided by the browser^M
// Do not require fs since file system is not available anyway^M
define([], _jsonix_factory);^M
}^M
}^M
Uncaught Error: define cannot be used indirect
at webpackJsonp.219.module.exports (amd-define.js:2)
at Object.<anonymous> (jsonix.js:6103)
at Object.118 (jsonix.js:6129)
at __webpack_require__ (bootstrap f29fa90…:1336)
at fn (bootstrap f29fa90…:754)
at Object.117 (WFS110Context.js:7)
at __webpack_require__ (bootstrap f29fa90…:1336)
at fn (bootstrap f29fa90…:754)
at Object.230 (SMIL_2_0.js:251)
at __webpack_require__ (bootstrap f29fa90…:1336)
I thought webpack was supposed to play nicely with this kind of thing.
Actually I wonder if we can get the error reproduced by using the command-line tool, since the error only occurs in the browser with the webpack dev server
for the jsonix module it sets require to false (so jsonix thinks it runs in the browser)
it exports the global variable Jsonix, so that it can be used in ES6 import statements
@highsource the code that checks in which context Jsonix is running should also check for the ES6 import statement, which is the mostly used way to import modules in webpack. So it would happily run with webpack as well as with native ES6 imports. Thanks for that great library :-)
Activity
WillieMaddox commentedon Jun 22, 2017
I'm getting the error as well,
I thought webpack was supposed to play nicely with this kind of thing.
bartvde commentedon Jun 22, 2017
@WillieMaddox I made some fixes in a fork https://github.com/boundlessgeo/jsonix/commits/master and published as
@boundlessgeo/jsonixfor now, until we get the mainstream version fixedLet me know if it works for you or not.
highsource commentedon Jun 27, 2017
Could you please PR a reproducing project?
Under jsonix/nodejs/tests/webpack2 analog to browserify.
bartvde commentedon Jun 27, 2017
Sure I will do that @highsource
bartvde commentedon Jun 28, 2017
Actually I wonder if we can get the error reproduced by using the command-line tool, since the error only occurs in the browser with the webpack dev server
bartvde commentedon Jun 28, 2017
yeah command-line it works fine
pmeller commentedon Mar 7, 2018
I can confim that problem still exists for webpack 3.10 and webpack-dev-server 2.11.1.
HugoJBello commentedon Nov 15, 2018
Hi, I see that this was apparently fixed. I see that there has not been any build in npm. Could you publish it in npm please?
mbaer3000 commentedon Nov 26, 2018
Looks like planetfederal@3342c01 was never PRed and/or merged here. So it looks to me like the issue is actually not fixed.
@bartvde, if it works for you, then best PR your fix here?
bartvde commentedon Nov 26, 2018
Right IIRC the issue was that I could not create a test case that failed
dubst3pp4 commentedon Feb 14, 2020
Hi, any news or workarounds for this? I'm using webpack 4.x and the error still occurs.
dubst3pp4 commentedon Feb 14, 2020
Okay, I could get a workaround for webpack as follows:
Install
imports-loaderandexports-loaderand add the following rule towebpack.config.js:You can then import
Jsonixlike so:The webpack-rule does the following:
jsonixis loadedjsonixmodule it setsrequireto false (sojsonixthinks it runs in the browser)Jsonix, so that it can be used in ES6importstatements@highsource the code that checks in which context Jsonix is running should also check for the ES6
importstatement, which is the mostly used way to import modules in webpack. So it would happily run with webpack as well as with native ES6 imports. Thanks for that great library :-)GFdevelop commentedon Aug 18, 2020
On new versions of imports/exports-loader (I'm using v1.1.0) the equivalent syntax is: