diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 095730019..000000000 --- a/.babelrc +++ /dev/null @@ -1,22 +0,0 @@ -{ - "plugins": [ - "@babel/plugin-proposal-function-bind", - "@babel/plugin-transform-shorthand-properties" - ], - "presets": [ - ["@babel/preset-env", {"targets": "maintained node versions"}] - ], - "env": { - "test_coverage": { - "plugins": [ - ["istanbul", {"exclude": ["test/*.js", "**/*_spec.js"]}] - ] - }, - "browser": { - "presets": [ - ["@babel/preset-env", {"targets": "last 2 versions", "useBuiltIns": "usage"}] - ] - } - }, - "sourceMaps": true -} diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 000000000..0a78d4dca --- /dev/null +++ b/babel.config.js @@ -0,0 +1,27 @@ +module.exports = { + plugins: [ + "@babel/plugin-proposal-function-bind", + "@babel/plugin-transform-shorthand-properties" + ], + presets: [ + ["@babel/preset-env", {targets: "maintained node versions"}] + ], + env: { + test_coverage: { + plugins: [ + ["istanbul", {exclude: ["test/*.js", "**/*_spec.js"]}] + ] + }, + browser: { + presets: [ + ["@babel/preset-env", { + targets: "last 2 versions", + useBuiltIns: "entry", + corejs: 3, + shippedProposals: true + }] + ] + } + }, + sourceMaps: true +} diff --git a/features/support/hooks.js b/features/support/hooks.js index 65f352713..afd23ac66 100644 --- a/features/support/hooks.js +++ b/features/support/hooks.js @@ -8,6 +8,7 @@ import tmp from 'tmp' const projectPath = path.join(__dirname, '..', '..') const projectNodeModulesPath = path.join(projectPath, 'node_modules') +const projectBabelConfigPath = path.join(projectPath, 'babel.config.js') const moduleNames = fs.readdirSync(projectNodeModulesPath) Before('@debug', function() { @@ -28,6 +29,9 @@ Before(function({ sourceLocation: { uri, line } }) { 'module.exports = {default: "--require-module @babel/register"}' fsExtra.outputFileSync(tmpDirProfilePath, profileContent) + const tmpDirBabelConfigPath = path.join(this.tmpDir, 'babel.config.js') + fsExtra.createSymlinkSync(projectBabelConfigPath, tmpDirBabelConfigPath) + const tmpDirNodeModulesPath = path.join(this.tmpDir, 'node_modules') const tmpDirCucumberPath = path.join(tmpDirNodeModulesPath, 'cucumber') fsExtra.createSymlinkSync(projectPath, tmpDirCucumberPath) diff --git a/package.json b/package.json index 0584addb3..3803b48d4 100644 --- a/package.json +++ b/package.json @@ -188,6 +188,7 @@ "chai": "^4.0.1", "coffeescript": "^2.4.1", "connect": "^3.4.0", + "core-js": "^3.2.1", "coveralls": "^3.0.0", "dependency-lint": "^6.0.0", "eslint": "^6.3.0", @@ -204,6 +205,7 @@ "mustache": "^3.0.1", "nyc": "^14.0.0", "prettier": "^1.5.2", + "regenerator-runtime": "^0.13.3", "serve-static": "^1.10.0", "sinon": "^7.3.1", "sinon-chai": "^3.3.0", @@ -214,7 +216,7 @@ "build-browser-example": "BABEL_ENV=browser browserify example/index.js -o dist/browser-example.js -t babelify", "build-local-continuous": "babel src --watch -d lib --ignore '**/*_spec.js'", "build-local": "babel src -d lib --ignore '**/*_spec.js'", - "build-release": "BABEL_ENV=browser browserify src/index.js -o dist/cucumber.js -t babelify --standalone Cucumber", + "build-release": "BABEL_ENV=browser browserify scripts/cucumber.js -o dist/cucumber.js -t babelify --standalone Cucumber --debug", "feature-test": "node ./bin/cucumber-js", "lint-autofix": "eslint --fix \"{example,features,scripts,src,test}/**/*.js\"", "lint-code": "eslint \"{example,features,scripts,src,test}/**/*.js\"", diff --git a/scripts/cucumber.js b/scripts/cucumber.js new file mode 100644 index 000000000..25f6473ce --- /dev/null +++ b/scripts/cucumber.js @@ -0,0 +1,5 @@ +// File to be browserified to create dist + +import 'core-js/stable' +import 'regenerator-runtime/runtime' +export * from '../src/index' diff --git a/yarn.lock b/yarn.lock index 8a1fe13ea..35f34f307 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1566,7 +1566,7 @@ core-js@^2.6.5: resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.9.tgz#6b4b214620c834152e179323727fc19741b084f2" integrity sha512-HOpZf6eXmnl7la+cUdMnLvUxKNqLUzJvgIziQ0DiF3JwSImNphIqdGqzj6hIKyX04MmV0poclQ7+wjWvxQyR2A== -core-js@^3.0.0: +core-js@^3.0.0, core-js@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.2.1.tgz#cd41f38534da6cc59f7db050fe67307de9868b09" integrity sha512-Qa5XSVefSVPRxy2XfUC13WbvqkxhkwB3ve+pgCQveNgYzbM/UxZeu1dcOX/xr4UmfUd+muuvsaxilQzCyUurMw== @@ -4539,7 +4539,7 @@ regenerate@^1.4.0: resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.0.tgz#4a856ec4b56e4077c557589cae85e7a4c8869a11" integrity sha512-1G6jJVDWrt0rK99kBjvEtziZNCICAuvIPkSiUFIQxVP06RCVpq3dmDo2oi6ABpYaDYaTRr67BEhL8r1wgEZZKg== -regenerator-runtime@^0.13.2: +regenerator-runtime@^0.13.2, regenerator-runtime@^0.13.3: version "0.13.3" resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz#7cf6a77d8f5c6f60eb73c5fc1955b2ceb01e6bf5" integrity sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw==