rollup-plugin-typescript2: watch mode error for non-TS files (Handlebars, Vue)

I import Handlebars template files which should be ignored by the diagnostics.

Error: Could not find file: '/Users/mohamed/project/src/Views/Shared/spaces.hbs'.
    at getValidSourceFile (/Users/mohamed/project/node_modules/typescript/lib/typescript.js:91281:23)
    at Object.getSyntacticDiagnostics (/Users/mohamed/project/node_modules/typescript/lib/typescript.js:91504:52)
    at /Users/mohamed/project/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:629:74
    at /Users/mohamed/project/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:325:80
    at arrayEach (/Users/mohamed/project/node_modules/rollup-plugin-typescript2/node_modules/lodash/lodash.js:537:11)
    at Function.forEach (/Users/mohamed/project/node_modules/rollup-plugin-typescript2/node_modules/lodash/lodash.js:9359:14)
    at TsCache.walkTree (/Users/mohamed/project/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:325:9)
    at Object.ongenerate (/Users/mohamed/project/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:628:17)
    at bundle.plugins.forEach.plugin (/Users/mohamed/project/node_modules/rollup/dist/rollup.js:10507:16)
    at Array.forEach (<anonymous>)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 22 (9 by maintainers)

Commits related to this issue

Most upvoted comments

I’ve been testing the master branch for a while. So far so good. I think this is it. Thank you 😄

It’s been two days. Everything is fine. I think you can release the patch now. Thank you.

Ok, finally got around to it, @hiendv could you check if master works for you?

@ezolenko @ezolenko2 Could you look at this? Thanks. https://github.com/hiendv/rpt2-vue-issue-32

Edit 1: Add a screen cast peek

I’m on it but it’s kinda hard because of the random appearance of the error.

Hah, yeah it seems fine now 😄

I do import them like so:

import template from '../Views/Shared/ads.hbs';

with declaration elsewhere:

declare module '*.hbs' {
  export default function (context: any): string;
}

It doesn’t happen in a non-watch build.

rollup.config.js:

import commonjs from 'rollup-plugin-commonjs';
import handlebars from 'rollup-plugin-handlebars-plus';
import json from 'rollup-plugin-json';
import resolve from 'rollup-plugin-node-resolve';
import rootImport from 'rollup-plugin-root-import';
import typescript from 'rollup-plugin-typescript2';
import uglify from 'rollup-plugin-uglify';

const partialRoot = `${__dirname}/src/Views/Shared`;

export default {
  output: {
    format: 'iife'
  },
  plugins: [
    typescript({ clean: true }),
    json(),
    resolve(),
    commonjs(),
    rootImport({ root: partialRoot }),
    handlebars({
      helpers: '../../ts/handlebars',
      partialRoot: partialRoot,
      isPartial: () => true
    }),
    uglify()
  ]
}

tsconfig.json

{
  "compilerOptions": {
    "downlevelIteration": true,
    "lib": [
      "dom",
      "dom.iterable",
      "es2017"
    ],
    "moduleResolution": "node",
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "strict": true,
    "target": "es5"
  }
}