feat: auto alias for fleck

This commit is contained in:
cha0s 2022-02-26 09:45:46 -06:00
parent 1f0bfce3ba
commit 8806d12d04

View File

@ -7,6 +7,10 @@ const {
const R = require('./require'); const R = require('./require');
const {
FLECKS_ROOT = process.cwd(),
} = process.env;
const resolver = (source) => (path) => { const resolver = (source) => (path) => {
// Does the file resolve as source? // Does the file resolve as source?
try { try {
@ -27,9 +31,12 @@ const resolver = (source) => (path) => {
}; };
module.exports = () => (neutrino) => { module.exports = () => (neutrino) => {
const {packageJson: {files = []}, source} = neutrino.options; const {packageJson: {name, files = []}, source} = neutrino.options;
// index is not taken for granted. // index is not taken for granted.
neutrino.config.entryPoints.delete('index'); neutrino.config.entryPoints.delete('index');
// Alias this package.
neutrino.config.resolve.alias
.set(name, join(FLECKS_ROOT, 'src'));
// Calculate entry points from `files`. // Calculate entry points from `files`.
files files
.filter(resolver(source)) .filter(resolver(source))