Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rollup fails to resolve entry file when using --watch, seemingly at random #982

Closed
hpfast opened this issue Sep 24, 2016 · 29 comments
Closed

Comments

@hpfast
Copy link

hpfast commented Sep 24, 2016

I'm just trying rollup for the first time and cannot figure this error out involving --watch. I've set up a simple project and compile src/scripts/main.js to build/js/main.min.js. As the console output below shows, I save the source file multiple times (sometimes with a change, sometimes without) until eventually I get this error. The number of times it succeeds varies, and I can't tell if waiting longer helps.

I've gradually stripped out all plugins from my rollup.config.js. I was using uglify, replace, babel, eslint, commonjs, and resolve, but the error persists even with the following config:

   export default {
     entry: 'src/scripts/main.js',
     dest: 'build/js/main.min.js',
     format: 'iife',
     sourceMap: 'inline'
   };

I have rollup-watch installed locally because rollup complains it can't find it globally (I think because on Ubuntu I have to use sudo to install it globally)

Console output:

 hans@vast  ~/priv/prj/foo  npm run watch-js

> foo@1.0.0 watch-js /home/hans/priv/prj/foo
> rollup -c -w

checking rollup-watch version...
bundling...
bundled in 26ms. Watching for changes...
bundling...
bundled in 12ms. Watching for changes...
bundling...
bundled in 17ms. Watching for changes...
bundling...
bundled in 8ms. Watching for changes...
bundling...
bundled in 14ms. Watching for changes...
bundling...
Could not resolve entry (src/scripts/main.js)
Error: Could not resolve entry (src/scripts/main.js)
    at /home/hans/priv/prj/foo/node_modules/rollup/src/Bundle.js:97:29
    at process._tickCallback (internal/process/next_tick.js:103:7)
Type rollup --help for help, or visit https://github.com/rollup/rollup/wiki
@hpfast
Copy link
Author

hpfast commented Sep 24, 2016

my setup here: https://github.com/hpfast/rollup-error

@hpfast
Copy link
Author

hpfast commented Sep 27, 2016

I wonder if I'm hitting something like this issue in rollup-watch? rollup/rollup-watch#4

I have the problem when using Vim, but not with Leafpad.

@Victorystick
Copy link
Contributor

If the problem is editor dependent, I've experienced something similar using Sublime Text. There was an atomic save mode which for every save created a new file and renamed it. It may be that you're experiencing something similar with Vim and Leafpad. Are you having this issue with the latest version of rollup-watch?

@hpfast
Copy link
Author

hpfast commented Sep 28, 2016

Hi,
yes, I'm using the latest version of rollup-watch, running node 6.6.0 on Ubuntu. I have the issue in Vim, not Leafpad, and with inotifywait and fs.watch() I can see that Vim indeed is deleting and replacing the file whereas Leafpad sticks to modifying, opening and closing.

I wonder what this means for the general topic of watching for changes (see my back-reference from rollup/rollup-watch#16), but since digging into that is a bit above my head I think I'll try a workaround for now, and just use a separate file watcher (nodemon, etc) to retrigger rollup. The project I'm working on atm is small enough that I can live without incremental rebuilds for now.

@chiel
Copy link

chiel commented Oct 3, 2016

I'm running into similar issues - funnily enough it does not seem to happen when I use the node-resolve and commonjs plugins - I guess because there are no external dependencies then. Using that for my client-side code, sadly does not seem to work for the server.

@hpfast
Copy link
Author

hpfast commented Oct 3, 2016

I just came across this, apparently you can configure Vim to write a new file or not:

https://webpack.github.io/docs/webpack-dev-server.html#working-with-editors-ides-supporting-safe-write

it looks like this would be a good workaround for Vim users. I'll try it in a bit.

@Victorystick
Copy link
Contributor

@hpfast 👍 Although the issue should be addressed eventually.

@chiel
Copy link

chiel commented Oct 4, 2016

I tried what @hpfast linked, setting vim config modes, but it does not seem to fix the issue, I can reliably reproduce the issue, so I've encapsulated it in this repository/branch:

https://github.com/chielkunkels/rollup-issue/tree/issue2

Steps to reproduce:

  1. git clone git@github.com:chielkunkels/rollup-issue.git
  2. cd rollup-issue
  3. git checkout issue2
  4. npm install
  5. rollup -c -w

At this point everything is working fine, the initial build goes fine - one thing to note at this point is that it says Treating 'express' as external dependency, which is fine since we don't need to include this dependency in our server-side code.

However, when you try to edit hello-world.js to add, for example console.log('hello'), the watch mode will die:

Could not load express (imported by /Users/chiel/dev/rollup-issue/src/index.js): ENOENT: no such file or directory, open 'express'
Error: Could not load express (imported by /Users/chiel/dev/rollup-issue/src/index.js): ENOENT: no such file or directory, open 'express'
    at /Users/chiel/dev/rollup-issue/node_modules/rollup/src/Bundle.js:235:11
    at process._tickCallback (internal/process/next_tick.js:103:7)

Hopefully this can aid in tracking down the issue.

@chiel
Copy link

chiel commented Oct 4, 2016

One thing to note, is that it only breaks when saving hello-world.js. If you save the index.js, the build works just fine.

@chiel
Copy link

chiel commented Oct 20, 2016

Did anyone have any chance to look into this at all? I'm more than willing to help if I get some kind of pointer on where to start.

@EmielM
Copy link

EmielM commented Oct 28, 2016

Hey @chielkunkels 👋, patch above is a workaround. See pr #1087.

@chiel
Copy link

chiel commented Nov 9, 2016

Hah, hey @EmielM - I'm actually transpiling my server-side code purely with babel now, to circumvent this issue. If I run into it again I will definitely check out the patch though.

@philippotto
Copy link

I'm experiencing the same issue on Ubuntu.

@chiel
Copy link

chiel commented May 18, 2017

I am actually still getting this issue on OS X as well.

@Finesse
Copy link

Finesse commented Oct 15, 2017

I still face this issue but I use cache instead of watch fixed in 0.50.0

@nolanlawson
Copy link
Contributor

Can this issue be closed?

@ghost
Copy link

ghost commented Jul 16, 2018

@nolanlawson, it still happens here on osx

"rollup": "^0.62.0",
"rollup-watch": "^4.3.1"

update: looks it just happens if i use rollup-plugin-typescript2, ill dig deeper ;)
update 2: rollup-plugin-typescript2 fixes the issue, everything woks as expected now

@ethanyou725
Copy link

the same,

"@types/jest": "^23.1.2",
    "axios": "^0.17.0",
    "babel-loader": "^7.1.4",
    "cross-env": "^5.2.0",
    "jest": "^23.2.0",
    "mobx": "^4.3.1",
    "npm-run-all": "^4.1.3",
    "prettier": "^1.13.5",
    "rimraf": "^2.6.2",
    "rollup": "^0.62.0",
    "rollup-plugin-alias": "^1.4.0",
    "rollup-plugin-node-resolve": "^3.3.0",
    "rollup-plugin-replace": "^2.0.0",
    "rollup-plugin-tslint": "^0.1.34",
    "rollup-plugin-typescript2": "^0.15.1",
    "rollup-plugin-uglify-es": "^0.0.1",
    "ts-jest": "^22.4.6",
    "ts-loader": "^4.4.1",
    "tslint": "^5.10.0",
    "typescript": "2.8.1",
    "uglify-es": "^3.3.9"

config

const plugins = (tsConfig = {}) => [
  // tslint(),
  typescript({
    tsconfig: "tsconfig.json",
    tsconfigOverride: tsConfig,
    typescript: typescriptComplier,
    useTsconfigDeclarationDir: true,
    include: ["src/**/*.ts"]
  }),
  replace({
    __VERSION__: version
  })
];

export default [
  // ES module unminified
  {
    input: "src/index.ts",
    external: ["axios", "mobx"],
    plugins: plugins({
      compilerOptions: {
        target: "ES6",
        declaration: true
      }
    }),
    output: {
      file: "dist/index.es.js",
      format: "es"
    }
  }
];

rollup -w -c build/rollup.dev.js

@xwisdom
Copy link

xwisdom commented Oct 17, 2018

I've logged a separate issue for the error I'm getting while using watch mode - #2513

@eljenso
Copy link

eljenso commented Oct 24, 2018

Is there any workaround for this?

LoicMahieu added a commit to LoicMahieu/rollup-bug-982 that referenced this issue Nov 6, 2018
@LoicMahieu
Copy link

LoicMahieu commented Nov 6, 2018

I created a minimum minimum minimum repo for this issue:
https://github.com/LoicMahieu/rollup-bug-982

  1. npm start
  2. Open file src/index.js
  3. Just hit save and see the error:
ENOENT: no such file or directory, open 'react'
  • Tested with rollup@0.67.0 and node@10.10
  • Tested with rollup@master

@LoicMahieu
Copy link

I am new in the rollup code base but it seems that:

  • During the first build, no problem
  • The second build, the ENOENT error comes from getRollupDefaultPlugin().load where it try to fs.readFileSync('react')which obviously throw this error.
  • During the first build, getRollupDefaultPlugin().load is not called.

@XindaSayHi
Copy link

I am new in the rollup code base but it seems that:

  • During the first build, no problem
  • The second build, the ENOENT error comes from getRollupDefaultPlugin().load where it try to fs.readFileSync('react')which obviously throw this error.
  • During the first build, getRollupDefaultPlugin().load is not called.

I have the same problem. Have you solved the problem?

@berkaytheunicorn
Copy link

same here

@shellscape
Copy link
Contributor

@XindaSayHi @berkaey check out https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/. much more effective and less spammy than comments for reporting same behavior 😉

@berkaytheunicorn
Copy link

@shellscape correct! but I did it intentionally so the issue can resolve most importantly you guys are be sure is the issue is really an issue, I wasn't sure if it is fixed or not (think my problem could be related to my codebase because original issue created on Sep 24, 2016) anyways, will do that from now on! thanks.

@macrozone
Copy link

@nolanlawson, it still happens here on osx

"rollup": "^0.62.0",
"rollup-watch": "^4.3.1"

update: looks it just happens if i use rollup-plugin-typescript2, ill dig deeper ;)
update 2: rollup-plugin-typescript2 fixes the issue, everything woks as expected now

I tried rollup-plugin-typescript2 but i still have the same error. Any idea what's wrong?

@ctaylo21
Copy link

@nolanlawson, it still happens here on osx

"rollup": "^0.62.0",
"rollup-watch": "^4.3.1"

update: looks it just happens if i use rollup-plugin-typescript2, ill dig deeper ;)
update 2: rollup-plugin-typescript2 fixes the issue, everything woks as expected now

I tried rollup-plugin-typescript2 but i still have the same error. Any idea what's wrong?

I also get the same error using rollup 1.17 and rollup-plugin-typescript2 0.22.1.

If I save my entry file, it reloads correctly. If I save a dependency file, I get the error

Error: Could not find sourceFile: 'path/to/src/demo.tsx'

It's not random, though. It happens every time. I finally think I figured out the issue. I had a src/index.tsx that was my main entry point, and a src/demo.tsx for development (I'm building a react component, so the demo.tsx just actually rendered it to the DOM).

In my tsconfig.json, I had:

  "include": ["src/index.tsx", "./src/types.d.ts"],

which did not include my demo.tsx file. Once I added it, I was able to run watch mode succsefully.

  "include": ["src/index.tsx", "./src/types.d.ts", "src/demo.tsx"],

This is a pretty specific error, but someone else might run into it as well.

@shellscape
Copy link
Contributor

Hey folks. This is a saved-form message, but rest assured we mean every word. The Rollup team is attempting to clean up the Issues backlog in the hopes that the active and still-needed, still-relevant issues bubble up to the surface. With that, we're closing issues that have been open for an eon or two, and have gone stale like pirate hard-tack without activity.

We really appreciate the folks have taken the time to open and comment on this issue. Please don't confuse this closure with us not caring or dismissing your issue, feature request, discussion, or report. The issue will still be here, just in a closed state. If the issue pertains to a bug, please re-test for the bug on the latest version of Rollup and if present, please tag @shellscape and request a re-open, and we'll be happy to oblige.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests