-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from euberdeveloper/customize-matching
Customize matching
- Loading branch information
Showing
8 changed files
with
70 additions
and
4 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
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 function printText(txt) { | ||
console.log(txt); | ||
} |
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 @@ | ||
import fs from 'node:fs'; | ||
import { printText } from '@/util.js'; | ||
|
||
async function main() { | ||
const text = await fs.promises.readFile('./sample.txt', 'utf-8'); | ||
printText(text); | ||
} | ||
main(); |
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,13 @@ | ||
import generateAliasesResolver from '../../../index.js'; | ||
const aliases = { | ||
"@/": "dist/src/" | ||
}; | ||
const matcher = (path, alias) => { | ||
return ( | ||
path.indexOf(alias) === 0 && | ||
(path.length === alias.length || path[alias.length] === "/" || path[alias.length - 1] === "/") | ||
) | ||
}; | ||
export const resolve = generateAliasesResolver(aliases, { | ||
matcher | ||
}); |
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,15 @@ | ||
{ | ||
"name": "esm-module-alias-test", | ||
"version": "1.0.0", | ||
"description": "A test project for the npm module esm-module-alias", | ||
"type": "module", | ||
"exports": "./index.js", | ||
"scripts": { | ||
"test": "node --loader ./my-loader.mjs index.js" | ||
}, | ||
"engines": { | ||
"node": ">=14.16" | ||
}, | ||
"author": "Euber Developer <[email protected]>", | ||
"license": "ISC" | ||
} |
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,2 @@ | ||
Sopra la panca la capra campa, sotto la panca la capra crepa. | ||
Jeu tegnu tre ciucci zoppi, tie ci tre ciucci zoppi tei? |
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