adobe / adobe/es-modules-middleware

Documentation: hard to make it work on Karma

Open
#7 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2
Forks
2
PR merge metrics
No merged PRs in 30d

Description

I log my research here so that anybody that try to make this work could find it easily...

This setup is aimed at reworking node_modules folder, and not your own sources (my personal objective is to integrate Polymer and google material into my tests without transpiling them).

In karma.conf:
```
plugins: [
require('@adobe/es-modules-middleware'),
'karma-*',
],

middleware: ['es-modules'],

esModulesMiddleware: {
baseDir: 'node_modules',
paths: {
'/': path.join(__dirname, 'node_modules'), // Caution: if karma.conf is not in root folder, adapth this !
},
},
```

This setup will catch all calls made on "/node_modules" and rework them.

So, in your code, if you need the rework to work, you need absolute links:

import ... from "/node_modules/@polymer/..."

PS: my objective is very limited, I know :-)

Feel free to integrate this into the readme.md if necessary or to let this bug open as documentation

## Rationale

After digging a lot around, I found out that the middleware could not intercept calls made on /base if the file was found locally. So this is a workaround.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.