-
Hello, i am using naja on my website, and now i wanted to implement datagrid, but i have a problem implementing javascript assets with webpack. Im no expert in webpack. The loaders im trying to use are: const jQueryExpose = {
test: require.resolve('jquery'),
use: [
{
loader: 'expose-loader',
options: {
exposes: ["$", "jQuery"],
},
}
]
};
const NajaExpose = {
test: require.resolve('naja'),
use: [
{
loader: 'expose-loader',
options: {
exposes: ["naja", "window.naja", "document.naja"],
},
}
]
}; but when i build the bundle, it says
How am i supposed to expose naja for the datagrid to see it? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hello, you're not the first to encounter this kind of issue. Unfortunately, datagrid's assets are not so ready to be used as ES modules comfortably. In one of the threads on Nette forum, @f3l1x mentioned that they have plans to alleviate this. I've opened contributte/datagrid#942 to keep track of the progress. As for a solution until then, one which I believe is most likely to work is to use the ProvidePlugin, configured to expose new webpack.ProvidePlugin({
naja: ['naja', 'default'],
}); |
Beta Was this translation helpful? Give feedback.
-
Thanks for a fast answer, the I tried to use the ProvidePlugin after i seen your reply, but i had problems... const provide_Naja = new webpack.ProvidePlugin({
// naja: "naja", // This did not work
naja: path.resolve(path.join(__dirname, '/../node_modules/naja/dist/Naja.js')), // this DID work
}); But now i use what you wrote in your edit: const provide_Naja = new webpack.ProvidePlugin({
naja: ['naja', 'default'],
}); Thank you very much for your help and your time, everything is working now. If you could explain why Your beer is on the way! |
Beta Was this translation helpful? Give feedback.
Hello, you're not the first to encounter this kind of issue. Unfortunately, datagrid's assets are not so ready to be used as ES modules comfortably. In one of the threads on Nette forum, @f3l1x mentioned that they have plans to alleviate this. I've opened contributte/datagrid#942 to keep track of the progress.
As for a solution until then, one which I believe is most likely to work is to use the ProvidePlugin, configured to expose
naja
's default export: