-
Notifications
You must be signed in to change notification settings - Fork 43
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
babel prevents ESM import #77
Comments
I just tested and adding ESM export example: https://github.com/sindresorhus/del/blob/main/index.js. |
Seems to be fixed in https://github.com/Nerajno/gulp-jest/blob/master/src/index.js, it just lacks a new release. The reported repository on the last yarn / npmjs (4.0.4) release is https://github.com/aarontrank/gulp-jest and it's not using ESM at all. but it seems other package are redirecting to your repository |
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _pluginError = _interopRequireDefault(require("plugin-error"));
var _through = _interopRequireDefault(require("through2"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _require = require('@jest/core'),
runCLI = _require.runCLI;
var _default = function _default() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return _through["default"].obj(function (file, enc, cb) {
options = Object.assign({
rootDir: file ? process.cwd() : undefined
}, options);
runCLI(options, [options.rootDir]).then(function (_ref) {
var results = _ref.results;
if (results.numFailedTests || results.numFailedTestSuites) {
cb(new _pluginError["default"]('gulp-jest', {
message: 'Tests Failed'
}));
} else if (typeof results.success !== 'undefined' && !results.success) {
if (results.snapshot && results.snapshot.failure) {
cb(new _pluginError["default"]('gulp-jest', {
message: 'Tests Failed due to coverage snapshot failure'
}));
} else {
cb(new _pluginError["default"]('gulp-jest', {
message: 'Tests Failed due to coverage threshold breaches'
}));
}
} else {
cb();
}
});
});
};
exports["default"] = _default; |
gulp-js 4.0.4 package is up to date from this repository. It's babel that is generating this horrible code.
|
In https://www.bigbinary.com/blog/helping-babel-move-to-esm, they give an example where const rollupBabel = require("@rollup/plugin-babel").default; is replaced with import { babel as rollupBabel } from "@rollup/plugin-babel"; But replacing var jest = require('gulp-jest').default; with import { jest as gulpJest } from 'gulp-jest'; But it always end in:
I can't figure what is the export name. This doesn't work either. import * as gulpJest from 'gulp-jest'; |
This seems to be related to the usage of @babel/plugin-transform-modules-commonjs that is included in @babel/preset-env. |
Some projects like babel/babel#11701 has made some work to publish both as ESM or CJS cf. https://github.com/babel/babel/pull/13414/files |
Has there been any update on this as I'm also stuck at this point and may have to look at using different tools. |
No, the project seems abandoned. The author seems to only merge dependabot PR from times to times but as no been committing since April and has never given any answer for this issue for one year. The last npmjs release is 3 years old. I think I'll drop this dependency and replace the script: "scripts": {
- "test": "gulp test"
+ "test": "jest"
}, |
I'm trying to port the CommonJS (CJS) import to a ECMAScript Modules (ESM) import. cf. https://gist.github.com/noraj/007a943dc781dc8dd3198a29205bae04
From:
to
But it fails with the following error when running gulp:
However
node_modules/gulp-jest/lib/index.js
seems to have an uncommon way to export.Could you provide me an example to how to import gulp-jest in a
.mjs
file or maybe patch the export if it's the cause.The text was updated successfully, but these errors were encountered: