-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
316 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// https://github.com/viruscamp/babel-plugin-transform-imports#using-a-function-as-the-transformer | ||
|
||
const path = require('path'); | ||
const siteDir = path.resolve('./e2e/site'); | ||
const testsDir = path.resolve('./e2e/tests'); | ||
const testsBuiltDir = path.resolve('./e2e/dist'); | ||
|
||
module.exports = { | ||
presets: [ | ||
[ | ||
'@babel/env', | ||
{ | ||
modules: false, | ||
useBuiltIns: false, | ||
loose: true, | ||
targets: 'chrome > 100', | ||
}, | ||
], | ||
[ | ||
'@babel/typescript', | ||
{ | ||
allowDeclareFields: true, | ||
}, | ||
], | ||
], | ||
plugins: [ | ||
[ | ||
'transform-imports', | ||
{ | ||
'\\..*': { | ||
skipDefaultConversion: true, | ||
transform: function (importName, matches, filename) { | ||
const file = path.resolve( | ||
path.dirname(filename), | ||
`${matches[0]}.js` | ||
); | ||
return path | ||
.relative( | ||
siteDir, | ||
file.startsWith(testsDir) | ||
? path.resolve(testsBuiltDir, path.relative(testsDir, file)) | ||
: file | ||
) | ||
.replaceAll('\\', '/'); | ||
}, | ||
}, | ||
}, | ||
], | ||
], | ||
}; |
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,12 +1,12 @@ | ||
import { readJSONSync } from 'fs-extra'; | ||
|
||
/** | ||
* The import map used by `./utils/setupApp` to inject into the page | ||
* so test scripts can use modules (relative imports don't seem to work out of the box) | ||
* The import map used by `./utils/setupApp` to inject into the page so test scripts can use modules. | ||
* | ||
* Relative imports are supported thanks to babel, see `./.babelrc.js`. | ||
* | ||
* **IMPORTANT**: be sure to update the paths field in `./tsconfig.json` to reflect imports correctly | ||
*/ | ||
export default { | ||
fabric: readJSONSync('./package.json').module.slice(1), | ||
test: '/e2e/dist/test.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
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
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
Oops, something went wrong.