-
-
Notifications
You must be signed in to change notification settings - Fork 156
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
Unable to import #366
Comments
i was facing the same problem and issue solved by simply changing the version.
|
@macmichael01 You might want to read this gist about this exact problem mentioned in the release notes of v8. As far as i understand it correctly you can either migrate your project to use pure ESM, allowing the now required import syntax, or otherwise stick to the older version, as already mentioned by @ashishsaini0194. But since apart from the switch to ESM no other changes have taken place so far, it should be no problem to continue using 7.1.0 for now, I think. |
As I described neither ESM imports or the old require imports work. I also checked my node version (which is v14) to see if I am on the version of node that supports ESM imports (which is node v12). Anyone else having this issue? For now, I will continue using v7. |
Thanks for saving me the frustrations. Hope the dev fixes the issue. |
This change feels like a premature step. Gulp currently does not, by default, support ESM without the additional of extra dependencies, and asking people to migrate their entire Gulp configuration to support a single plugin is a pretty big (and somewhat developer-hostile) ask. It doesn't feel like too much to ask that a Gulp plugin be compatible with out-of-the-box Gulp. |
Not true, the dependency tree for 7.1.0 shows older svgo (1.3.2) whereas 8.0.0 uses 2.8.0. Unfortunately 8.0.0 is completely unusable due to ESM being a requirement. It's not a very user friendly change. Couldn't you compile a cjs file and push into dist? |
Hi all, const { src, dest } = require('gulp');
const gulpImagemin = require('gulp-imagemin');
const config = require('./helpers/getConfig.js');
module.exports = function imagemin() {
return src(['**/*.{png,jpg,gif,svg}', '!bg/icons-svg.svg'], {
cwd: config.dest.images,
})
.pipe(
gulpImagemin([
gulpImagemin.jpegtran({ progressive: true }),
gulpImagemin.optipng(),
gulpImagemin.gifsicle(),
gulpImagemin.svgo({
plugins: [
{
removeViewBox: false,
},
],
}),
]),
)
.pipe(dest(config.dest.images));
}; to const { src, dest } = require('gulp');
const config = require('./helpers/getConfig.js');
module.exports = function imagemin() {
return import('gulp-imagemin').then((gulpImagemin) => {
src(['**/*.{png,jpg,gif,svg}', '!bg/icons-svg.svg'], {
cwd: config.dest.images,
})
.pipe(
gulpImagemin.default([
gulpImagemin.mozjpeg({ progressive: true }),
gulpImagemin.optipng(),
gulpImagemin.gifsicle(),
gulpImagemin.svgo(),
]),
)
.pipe(dest(config.dest.images));
});
}; |
I ran into the same issue that @michalmatuska did, and the dynamic import did the trick, but I also wanted to point out that removing the plugins for svgo was also a change that I needed to make - for some reason with plugins provided, it would skip over the next pipe (i.e. moving the files to their destination), but was not outputting any errors. It does not appear to be limited to |
I keep getting Task never defined errors on this. |
Good day, I have built a package inspired by these ES6 to CommonJS compatibility issues. Using gulp-imagemin as the test package I have created a PR which adds in a cjs subdirectory so that we can continue to use this lovely package in our latest gulp configurations. Hopefully this goes well, otherwise for anyone interested in resolving this for their own purposes you can check out my package for |
When I do:
I get:
When I do:
I get:
What is the correct way to import? Thanks!
The text was updated successfully, but these errors were encountered: