egoist / bili

Bili makes it easier to bundle JavaScript libraries.

Home Page:https://bili.egoist.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot find module from directory with index file

samrith-s opened this issue · comments

Hey,

I've been using Bili for quite a few packages and it has worked well so far. We have our API, which uses ES6. It has a lot of index.js files, and we import them like so:

import resolvers from './resolvers'

And the resolvers/index.js is as follows:

import Query from './queries';
import Mutation from './mutations';
import types from './types';

export default {
    Query,
    Mutation,
    ...types
};

After the build, when I try running node build/server.js I get the error:

internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module 'resolvers'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/Users/sam/Work/totem/systems/api/build/server.js:1:327)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)

Idk what I'm doing wrong here. I see you already have rollup-plugin-node-resolve included. I don't know why it's unable to find the file, and has not compiled it into the bundle.

Here is my bili.config.js:

module.exports = {
    input: 'src/server.js',
    output: {
        dir: 'build',
        fileName: '[name][min][ext]',
        format: 'cjs',
        minify: process.env.NODE_ENV === "production",
        sourceMap: true
    },
    bundleNodeModules: true,
    env: process.env.NODE_ENV
}

Everything builds properly, but I can't run it.

Thanks!

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.68. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@samrith-s Any update on this one? I am facing the very same issue.

I’ve stopped using bili. Switched to webpack or TS for all of my project.

commented

I'd like to fix this bug. I tried to reproduce this bug but I failed... Would like to provide a minimal repro repo?