diff --git a/jest-transformer.js b/jest-transformer.js index 072aba2e1ecc4..0532d3176f793 100644 --- a/jest-transformer.js +++ b/jest-transformer.js @@ -1,2 +1,5 @@ const babelPreset = require(`babel-preset-gatsby-package`)() -module.exports = require(`babel-jest`).createTransformer(babelPreset) +module.exports = require(`babel-jest`).createTransformer({ + ...babelPreset, + plugins: [...babelPreset.plugins, `babel-plugin-dynamic-import-node`], +}) diff --git a/jest.config.js b/jest.config.js index 34ee91a784814..02f00bf47814a 100644 --- a/jest.config.js +++ b/jest.config.js @@ -35,9 +35,7 @@ module.exports = { ], // gatsby-image includes a dynamic import in the IE polyfill // that Node doesn't understand and needs `babel-plugin-dynamic-import-node` - // transformIgnorePatterns: [ - // `/node_modules\/(?!gatsby-image\/withIEPolyfill).*/`, - // ], + // transformIgnorePatterns: [`/node_modules/`], transform: { "^.+\\.js$": `/jest-transformer.js` }, moduleNameMapper: { "^highlight.js$": `/node_modules/highlight.js/lib/index.js`, diff --git a/package.json b/package.json index ee419fefe32e9..155088359ec00 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "@babel/runtime": "^7.0.0", "babel-eslint": "^10.0.1", "babel-jest": "^24.0.0", + "babel-plugin-dynamic-import-node": "^2.3.0", "chokidar": "^1.7.0", "cross-env": "^5.1.4", "eslint": "^5.16.0", diff --git a/yarn.lock b/yarn.lock index ca26934352770..85aefafa2a19e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4277,6 +4277,13 @@ babel-plugin-dynamic-import-node@^1.2.0: dependencies: babel-plugin-syntax-dynamic-import "^6.18.0" +babel-plugin-dynamic-import-node@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.0.tgz#f00f507bdaa3c3e3ff6e7e5e98d90a7acab96f7f" + integrity sha512-o6qFkpeQEBxcqt0XYlWzAVxNCSCZdUgcR8IRlhD/8DylxjjO4foPcvTW0GGKa/cVt3rvxZ7o5ippJ+/0nvLhlQ== + dependencies: + object.assign "^4.1.0" + babel-plugin-emotion@^10.0.7: version "10.0.7" resolved "https://registry.yarnpkg.com/babel-plugin-emotion/-/babel-plugin-emotion-10.0.7.tgz#3634ada6dee762140f27db07387feaec8d2cb619" @@ -15891,7 +15898,7 @@ object-visit@^1.0.0: dependencies: isobject "^3.0.0" -object.assign@^4.0.4: +object.assign@^4.0.4, object.assign@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.0.tgz#968bf1100d7956bb3ca086f006f846b3bc4008da" integrity sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==