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

Can't use this plugin with rollup watch #6

Closed
sateffen opened this issue Mar 12, 2017 · 9 comments
Closed

Can't use this plugin with rollup watch #6

sateffen opened this issue Mar 12, 2017 · 9 comments
Assignees
Labels
kind: feature New feature or request kind: optimization Performance, space, size, etc improvement scope: watch mode Related to Rollup's watch mode
Milestone

Comments

@sateffen
Copy link

When using rollup in watch mode (rollup --watch) this plugin will allow the first build but no following one. Each time I change a file it tells me:

bundling...
� ENOENT: no such file or directory, open '.../.cache/rollup-plugin-typescript2/38c1142761dfd23593156a9ffdbc77dede334f14/code/cache_/ff351ee7256cf7
98f62b4f46f09ac4534010406c'
src/gl/gl.tsx

The file does not exist, but I guess it's the hash of the new file. In this scenario, I changed some code in src/gl/gl.tsx, which lead to the rebuild.

Stopping rollup --watch and rerunning it generates a valid bundle, but every following build afterwards are breaking as well.

I'm using rollup 0.41.5, rollup-plugin-typescript2 0.3.0 and node 6.9.1

@ezolenko ezolenko self-assigned this Mar 12, 2017
ezolenko added a commit that referenced this issue Mar 13, 2017
@ezolenko
Copy link
Owner

I got over that one in the watch branch somewhat. But there is a bigger problem -- rollup-watch only looks at modules that rollup sees, and that excludes any type-only imports and all d.ts files. Basically every time ts will not generate a require call, rollup will not see that file. So you can mutilate your interface definitions all you want, rollup won't try to transpile that file or anything that imports it.

@sateffen
Copy link
Author

In my opinion that's ok, if it's pointed out in the documentation.

the d.ts files are meta information, that append the usual information. It's not that cool, that the d.ts changes get ignored, but it's actually something I personally could work with. The most important thing is to tell it straight forward in the documentation.

Maybe there'll be an option for this in the future, or the guys from rollup know a possible solution?

@ezolenko ezolenko added this to the 0.4.0 milestone Mar 13, 2017
ezolenko added a commit that referenced this issue Mar 15, 2017
* - partial fix for watch mode (#6)

* - trying to detect watch mode

* - support for watch mode
@ezolenko
Copy link
Owner

Could you try with master branch to see if it behaves reasonably?

@brandom
Copy link

brandom commented Mar 15, 2017

I just tried master with --watch and I get Cannot read property 'length' of undefined.

Compiles correctly but with similar error to above on file change on 0.3.0.

@ezolenko
Copy link
Owner

@brandom: what's your rollup config look like? I'm trying to detect watch mode by counting targets, maybe you don't have any defined...

@brandom
Copy link

brandom commented Mar 16, 2017

Rollup config

export default {
  format: "iife",
  sourceMap: true,
  plugins: [
    typescript({
      typescript: require("typescript")
    }),
    node({
      jsnext: true,
      main: true,
      browser: true
    }),
    commonjs(),
    babel({
      babelrc: false,
      exclude: "node_modules/**",
      presets: [
        "es2017",
        "es2016",
        [
          "es2015",
          {
            modules: false
          }
        ]
      ],
      plugins: ["lodash", "external-helpers"]
    })
  ],
  external: []
};

And then spawning --watch from within gulp

function devBundle(cb) {
  let rollup = spawn("./node_modules/.bin/rollup", [
    "-c",
    "rollup.config.dev.js",
    "--watch",
    "--input",
    "./components/app/App.ts",
    "--output",
    `./dist/js/${jsFileName}`
  ]);
  rollup.stderr.on("data", data => rollupLog(data));
  return rollup;
}

@ezolenko
Copy link
Owner

Ok, your config should work with master now I think (or at least get to the next bug :)).

I'm still seeing weird ignoring of bad edits in index file (while correct errors show up for edits in other files), so this is not quite ready for npm release.

@brandom
Copy link

brandom commented Mar 28, 2017

@ezolenko Thanks, I will try to find some time to do some additional testing this weekend.

@ezolenko
Copy link
Owner

ezolenko commented Apr 3, 2017

Ok, this is in 0.4.0 now, seems to work aside from #7.

@agilgur5 agilgur5 added kind: feature New feature or request kind: optimization Performance, space, size, etc improvement labels May 7, 2022
@agilgur5 agilgur5 added the scope: watch mode Related to Rollup's watch mode label Jun 9, 2022
Repository owner locked as resolved and limited conversation to collaborators Jun 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind: feature New feature or request kind: optimization Performance, space, size, etc improvement scope: watch mode Related to Rollup's watch mode
Projects
None yet
Development

No branches or pull requests

4 participants