-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...s/babel-preset-gatsby-package/lib/__tests__/fixtures/keep-dynamic-import/default/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export async function someFunction() { | ||
return await import(`path`); | ||
} |
12 changes: 12 additions & 0 deletions
12
.../babel-preset-gatsby-package/lib/__tests__/fixtures/keep-dynamic-import/default/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"use strict"; | ||
|
||
exports.__esModule = true; | ||
exports.someFunction = someFunction; | ||
|
||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
|
||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
|
||
async function someFunction() { | ||
return await Promise.resolve().then(() => _interopRequireWildcard(require(`path`))); | ||
} |
17 changes: 17 additions & 0 deletions
17
packages/babel-preset-gatsby-package/lib/__tests__/fixtures/keep-dynamic-import/options.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const path = require("path") | ||
|
||
// "babel-plugin-dynamic-import-node" is used in tests, so we force not a test environment | ||
process.env.BABEL_ENV = `not-a-test` | ||
|
||
module.exports = { | ||
sourceType: "module", | ||
presets: [ | ||
[path.resolve(__dirname, "../../../index.js"), | ||
{ | ||
keepDynamicImports: [`./packages/babel-preset-gatsby-package/lib/__tests__/fixtures/keep-dynamic-import/with-override/input.js`] | ||
} | ||
], | ||
], | ||
babelrc: false, | ||
configFile: false, | ||
} |
3 changes: 3 additions & 0 deletions
3
...l-preset-gatsby-package/lib/__tests__/fixtures/keep-dynamic-import/with-override/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export async function someFunction2() { | ||
return await import(`path`); | ||
} |
8 changes: 8 additions & 0 deletions
8
...-preset-gatsby-package/lib/__tests__/fixtures/keep-dynamic-import/with-override/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"use strict"; | ||
|
||
exports.__esModule = true; | ||
exports.someFunction2 = someFunction2; | ||
|
||
async function someFunction2() { | ||
return await import(`path`); | ||
} |
3 changes: 2 additions & 1 deletion
3
...tests__/babel-transform-compiler-flags.js → ...t-gatsby-package/lib/__tests__/plugins.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
const runner = require(`@babel/helper-plugin-test-runner`).default | ||
|
||
runner(__dirname) | ||
// runner(__dirname + `/compiler-flags`) | ||
runner(__dirname ) |