-
Notifications
You must be signed in to change notification settings - Fork 7
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
Loading ES modules for filters/extensions results in error #81
Comments
What is your node version? Can you make repo to reproduce error? |
Node version 10.15.1 I'll see if I can cook up a small repo. |
@ogonkov I've made a small repo that reproduces the error. https://github.com/gijswijs/simple-nunjucks-loader-test I feel that it might be the combination of filters with the html-webpack-plugin that causes the issue, but that is just speculation. |
Thank you, will look at this tomorrow |
Just for clarification, the error happens during Let me know if you need help. If you give some pointers, I could probably make a PR. |
I see error, from the first look you need |
You are right. module.exports = function filter(val, param) {
return `${val + param}`;
} And then it works. Could we handle this more gracefully? Either via webpack config, or via some other means? |
All filters in loader tests are es modules, so I think problem somewhere in config. I need to figure out what should be changed. I didn't have a chance to sort it out yesterday, I will return with update today. |
The problem is that filter is evaluated by nodejs first (without Webpack involved), that cause the error you see. I'm afraid you can't use ES syntax in filters and extensions at that moment. I will keep this issue open, and will investigate the ways to publish both ES and CommonJS versions. |
I thought it was Node v13.2.0 that already supported ES syntax? Anyway, I can live with the workaround for now. Once you publish a fix, I'll bump my Node version to >=13.9.0 (or 13.2.0) |
Thank you for your patience. Take a note, i'm just publish another loader update in 2.x trunk, with fix to built-in |
I have added esm sources to package. But now webpack become problem, because it is trying to import loader itself as CommonJS, while it have |
See this issue for more info: ogonkov/nunjucks-loader#81 I still use the work around for now. Which is fine in this simple environment.
@gijswijs i'm afraid it is not yet possible with webpack to run loader as ES module webpack/loader-runner@4f91458#r40487622 I will close this PR for now, but i will reopen it when ES support will come to webpack. |
Thanks for all the effort you put in. |
If I follow the documentation and use the Filters option to load a filter:
webpack.config.js
filter.js
error
I am using simple-nunjucks-loader version 2.0.0
The text was updated successfully, but these errors were encountered: