Skip to content

Commit 5e369ea

Browse files
committed
Update readme to reflect change in path resolving
1 parent 6c68732 commit 5e369ea

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
[Karma](http://karma-runner.github.io) preprocessor to resolve ES6 modules.
33

44
## The problem
5-
Karma can natively run ES6 modules when using a suitable environment (a modern browser). Browsers module implementation is limited however to local modules (i.e. `./foo.js`) and browsers will not resolve paths missing extension leaving that to the server.
5+
Karma can natively run ES6 modules when running in a suitable environment (a modern browser). Browsers module implementation is limited however to local modules (i.e. `./foo.js`) and browsers will not resolve paths missing extension leaving that to the server.
6+
7+
This preprocessor solves both problems by rewriting import declarations on the fly and replacing aliased paths with absolute ones as well as adding extensions if necessary allowing for native ES6 modules testing without compiling or bundling.
68

7-
This preprocessor solves both problems by rewriting import declarations on the fly and replacing aliased path with relative ones as well as adding extensions if necessary allowing for native ES6 modules testing without compiling or bundling.
89

910
## Installation
1011
```bash
@@ -18,16 +19,18 @@ Preprocessor is configured with `moduleResolverPreprocessor` field:
1819
module.exports = (config) => {
1920
config.set({
2021
files: [
21-
{type: 'module', pattern: 'test/**/*.js'},
22-
{type: 'module', pattern: 'alias-root/**/*.js'}
22+
{type: 'module', pattern: './test/**/*.js'},
23+
{type: 'module', pattern: './project/**/*.js'}
2324
],
2425
preprocessors: {
2526
'test/**/*.js': ['module-resolver']
2627
},
2728
moduleResolverPreprocessor: {
2829
addExtension: 'js',
2930
customResolver: null,
30-
aliases: {}
31+
aliases: {
32+
project: "./project"
33+
}
3134
}
3235
});
3336
};
@@ -54,7 +57,7 @@ import Bar from 'alias/bar.js';
5457

5558
Default value: `{}`
5659

57-
A hash map containing alias names and paths relative from karma `basePath`.
60+
A hash map containing alias names and paths relative to Karma `basePath`.
5861

5962
Example:
6063
```js
@@ -68,7 +71,7 @@ Example:
6871
import Foo from 'alias/foo';
6972

7073
// Rewrites to
71-
import Foo from '../relative/from/current/file/alias-root/foo';
74+
import Foo from '/Absolute/Path/To/alias-root/foo';
7275
```
7376

7477
#### `customResolver`
@@ -78,7 +81,7 @@ A function to be called instead of normal rewriting.
7881

7982
Takes a single argument: A string containing imported file path.
8083

81-
Return value: string.
84+
Return value: string, a new file path.
8285

8386
Example:
8487
```js
@@ -93,7 +96,7 @@ import Foo from 'foo';
9396
import Foo from 'http://example.com/foo';
9497
```
9598

96-
## Karma module support
97-
As of version 3.0.0 Karma has limited support of modules: It can integrated it, but there's [a bug](https://github.com/karma-runner/karma/issues/2955) preventing tests described in modules from running. It is fixed in develop branch, but there's no release with the fix and no information on when it's going to be available.
99+
## Karma ES6 modules support
100+
As of version `3.0.0` Karma has limited support of modules: It can integrate them, but there's [a bug](https://github.com/karma-runner/karma/issues/2955) preventing tests described in modules from running. It is fixed in develop branch, but there's no release with the fix and no information on when it's going to be available.
98101

99-
There are some workarounds for the issue: Using `customContextFile` to substitute 3.0.0 `context.html` with a newer one and delaying `__karma__.loaded` call until DOM `load` event, see Karma GitHub for details.
102+
There are some workarounds for the issue: Using `customContextFile` to substitute `3.0.0` `context.html` with a newer one and delaying `__karma__.loaded` call until DOM `load` event. See Karma GitHub for details.

0 commit comments

Comments
 (0)