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

Could not find file that is never imported and it does exist #96

Closed
AlgusDark opened this Issue Jul 4, 2018 · 3 comments

Comments

Projects
None yet
4 participants
@AlgusDark

AlgusDark commented Jul 4, 2018

What happens and why it is wrong

Rollup+typescript2 plugin can't find a file that already exists.

Versions

  • typescript: 2.9.2
  • rollup: 0.62.0
  • rollup-plugin-typescript2: 0.15.1

rollup.config.js

import nodeResolve from 'rollup-plugin-node-resolve'
import replace from 'rollup-plugin-replace'
import commonjs from 'rollup-plugin-commonjs'
import json from 'rollup-plugin-json'
import sourceMaps from 'rollup-plugin-sourcemaps'
import typescript from 'rollup-plugin-typescript2'
import { terser } from 'rollup-plugin-terser'
import pkg from './package.json'

const cjs = {
  format: 'cjs',
  exports: 'named',
}

const commonPlugins = [
  json(),
  typescript({
    useTsconfigDeclarationDir: true,
    typescript: require('typescript'),
    clean: true,
    verbosity: 3,
  }),
  commonjs({
    ignoreGlobal: true,
  }),
  nodeResolve({
    module: true,
    main: true,
  }),
  sourceMaps(),
  replace({
    __DEV__: JSON.stringify(false),
  }),
]

const configBase = {
  input: 'src/index.tsx',
  external: ['react', 'styled-components'].concat(
    Object.keys(pkg.dependencies),
    Object.keys(pkg.peerDependencies)
  ),
  plugins: commonPlugins,
  output: {
    globals: { react: 'React', styled: 'styled-components' },
    sourcemap: true,
  },
}

const umdBaseConfig = Object.assign({}, configBase, {
  output: Object.assign({}, configBase.output, {
    file: 'dist/bloomer.js',
    format: 'umd',
    name: 'Bloomer',
    exports: 'named',
  }),
  plugins: configBase.plugins.concat(
    replace({
      __SERVER__: JSON.stringify(false),
    })
  ),
})

const umdConfig = Object.assign({}, umdBaseConfig, {
  plugins: umdBaseConfig.plugins.concat(
    replace({
      'process.env.NODE_ENV': JSON.stringify('development'),
    })
  ),
})

const umdProdConfig = Object.assign({}, umdBaseConfig, {
  output: Object.assign({}, umdBaseConfig.output, {
    file: 'dist/bloomer.min.js',
  }),
  plugins: umdBaseConfig.plugins.concat([
    replace({
      'process.env.NODE_ENV': JSON.stringify('production'),
    }),
    terser(),
  ]),
})

const browserConfig = Object.assign({}, configBase, {
  output: [
    Object.assign({}, configBase.output, {
      file: 'dist/bloomer.browser.es.js',
      format: 'es',
    }),
    Object.assign({}, configBase.output, cjs, {
      file: 'dist/bloomer.browser.cjs.js',
    }),
  ],
})

const browserProdConfig = Object.assign({}, configBase, browserConfig, {
  output: [
    Object.assign({}, configBase.output, {
      file: 'dist/bloomer.browser.es.min.js',
      format: 'es',
    }),
    Object.assign({}, configBase.output, cjs, {
      file: 'dist/bloomer.browser.cjs.min.js',
    }),
  ],
  plugins: browserConfig.plugins.concat(
    replace({
      'process.env.NODE_ENV': JSON.stringify('production'),
    }),
    terser()
  ),
})

export default [umdConfig, umdProdConfig, browserConfig, browserProdConfig]

tsconfig.json

{
  "compilerOptions": {
    "moduleResolution": "node",
    "target": "es5",
    "module": "es2015",
    "jsx": "react",
    "lib": [
      "es5",
      "es6",
      "es7",
      "es2017",
      "dom"
    ],
    "removeComments": true,
    "strict": true,
    "sourceMap": true,
    "declaration": true,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "declarationDir": "dist/types",
    "outDir": "dist/lib",
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "rootDir": "src",
    "noImplicitAny": true,
    "strictNullChecks": true
  },
  "include": [
    "src/**/*"
  ],
  "exclude": [
    "node_modules",
    "**/*.spec.ts"
  ]
}

plugin output with verbosity 3

src/index.tsx → dist/bloomer.js...
rpt2: typescript version: 2.9.2
rpt2: tslib version: 1.9.2
rpt2: rollup-plugin-typescript2 version: 0.15.1
rpt2: plugin options:
{
    "useTsconfigDeclarationDir": true,
    "typescript": "version 2.9.2",
    "clean": true,
    "verbosity": 3,
    "check": true,
    "cacheRoot": "/bloomer/.rpt2_cache",
    "include": [
        "*.ts+(|x)",
        "**/*.ts+(|x)"
    ],
    "exclude": [
        "*.d.ts",
        "**/*.d.ts"
    ],
    "abortOnError": true,
    "rollupCommonJSResolveHack": false,
    "tsconfigOverride": {},
    "transformers": [],
    "tsconfigDefaults": {}
}
rpt2: rollup config:
{
    "external": [
        "react",
        "styled-components",
        "@types/acorn",
        "@types/chokidar",
        "magic-string",
        "source-map",
        "react",
        "styled-components",
        "",
        ""
    ],
    "inlineDynamicImports": false,
    "input": "src/index.tsx",
    "chunkGroupingSize": 5000,
    "perf": false,
    "plugins": [
        {
            "name": "json"
        },
        {
            "name": "rpt2"
        },
        {
            "name": "commonjs"
        },
        {
            "name": "node-resolve"
        },
        {
            "name": "sourcemaps"
        },
        {
            "name": "replace"
        },
        {
            "name": "replace"
        },
        {
            "name": "replace"
        }
    ],
    "entry": "src/index.tsx"
}
rpt2: built-in options overrides: {
    "noEmitHelpers": false,
    "importHelpers": true,
    "noResolve": false,
    "noEmit": false,
    "inlineSourceMap": false,
    "outDir": "/bloomer/.rpt2_cache/placeholder",
    "moduleResolution": 2
}
rpt2: parsed tsconfig: {
    "options": {
        "module": 5,
        "moduleResolution": 2,
        "target": 1,
        "jsx": 2,
        "lib": [
            "lib.es5.d.ts",
            "lib.es2015.d.ts",
            "lib.es2016.d.ts",
            "lib.es2017.d.ts",
            "lib.dom.d.ts"
        ],
        "removeComments": true,
        "strict": true,
        "sourceMap": true,
        "declaration": true,
        "allowSyntheticDefaultImports": true,
        "esModuleInterop": true,
        "declarationDir": "/bloomer/dist/types",
        "outDir": "/bloomer/.rpt2_cache/placeholder",
        "noImplicitReturns": true,
        "noImplicitThis": true,
        "rootDir": "/bloomer/src",
        "noImplicitAny": true,
        "strictNullChecks": true,
        "configFilePath": "/bloomer/tsconfig.json",
        "noEmitHelpers": false,
        "importHelpers": true,
        "noResolve": false,
        "noEmit": false,
        "inlineSourceMap": false
    },
    "fileNames": [
        "/bloomer/src/index.tsx",
        "/bloomer/src/styles/base/abc.tsx"
    ],
    "typeAcquisition": {
        "enable": false,
        "include": [],
        "exclude": []
    },
    "raw": {
        "compilerOptions": {
            "module": "es2015",
            "moduleResolution": "node",
            "target": "es5",
            "jsx": "react",
            "lib": [
                "es5",
                "es6",
                "es7",
                "es2017",
                "dom"
            ],
            "removeComments": true,
            "strict": true,
            "sourceMap": true,
            "declaration": true,
            "allowSyntheticDefaultImports": true,
            "esModuleInterop": true,
            "declarationDir": "dist/types",
            "outDir": "dist/lib",
            "noImplicitReturns": true,
            "noImplicitThis": true,
            "rootDir": "src",
            "noImplicitAny": true,
            "strictNullChecks": true
        },
        "include": [
            "src/**/*"
        ],
        "exclude": [
            "node_modules",
            "**/*.spec.ts"
        ]
    },
    "errors": [],
    "wildcardDirectories": {
        "/bloomer/src": 1
    },
    "compileOnSave": false,
    "configFileSpecs": {
        "includeSpecs": [
            "src/**/*"
        ],
        "excludeSpecs": [
            "node_modules",
            "**/*.spec.ts"
        ],
        "validatedIncludeSpecs": [
            "src/**/*"
        ],
        "validatedExcludeSpecs": [
            "node_modules",
            "**/*.spec.ts"
        ],
        "wildcardDirectories": {
            "/bloomer/src": 1
        }
    }
}
rpt2: included:
'[
    "*.ts+(|x)",
    "**/*.ts+(|x)"
]'
rpt2: excluded:
'[
    "*.d.ts",
    "**/*.d.ts"
]'
rpt2: Ambient types:
rpt2:     /bloomer/node_modules/@types/acorn/index.d.ts
rpt2:     /bloomer/node_modules/@types/chokidar/index.d.ts
rpt2:     /bloomer/node_modules/@types/estree/index.d.ts
rpt2:     /bloomer/node_modules/@types/events/index.d.ts
rpt2:     /bloomer/node_modules/@types/node/index.d.ts
rpt2:     /bloomer/node_modules/@types/react/index.d.ts
rpt2:     /bloomer/node_modules/@types/react-dom/index.d.ts
rpt2: ambient types changed, redoing all semantic diagnostics
rpt2: cleaning cache: /bloomer/.rpt2_cache/72a73769b7f3ce4c375cdcaae105b9851ab05a91
rpt2: transpiling '/bloomer/src/index.tsx'
rpt2:     cache: 'e37c43d94ea0620eb6be43be0bb5de57c470db27'
rpt2:     cache miss
rpt2:     cache: 'e37c43d94ea0620eb6be43be0bb5de57c470db27'
rpt2:     cache miss
rpt2:     cache: 'e37c43d94ea0620eb6be43be0bb5de57c470db27'
rpt2:     cache miss
rpt2: generated declarations for '/bloomer/src/index.tsx'
rpt2: generating target 1
rpt2: rolling caches
rpt2: generating missed declarations for '/bloomer/src/styles/base/abc.tsx'
[!] Error: Could not find file: '/bloomer/src/styles/base/abc.tsx'.
Error: Could not find file: '/bloomer/src/styles/base/abc.tsx'.
    at getValidSourceFile (/bloomer/node_modules/typescript/lib/typescript.js:107554:23)
    at Object.getEmitOutput (/bloomer/node_modules/typescript/lib/typescript.js:108052:30)
    at /bloomer/node_modules/rollup-plugin-typescript2/src/index.ts:311:29
    at arrayEach (/bloomer/node_modules/rollup-plugin-typescript2/node_modules/lodash/lodash.js:516:11)
    at forEach (/bloomer/node_modules/rollup-plugin-typescript2/node_modules/lodash/lodash.js:9342:14)
    at Object.onwrite (/bloomer/node_modules/rollup-plugin-typescript2/src/index.ts:305:5)
    at /bloomer/node_modules/rollup/dist/rollup.js:22076:39
    at Array.map (<anonymous>)
    at /bloomer/node_modules/rollup/dist/rollup.js:22075:18
    at <anonymous>

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bloomer@0.7.0 build: `rollup -c`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bloomer@0.7.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/JP22746/.npm/_logs/2018-07-04T04_25_56_757Z-debug.log

File /bloomer/src/styles/base/abc.tsx does exist, but is never imported. So I'm very confused right now.

@BenzLeung

This comment has been minimized.

BenzLeung commented Jul 4, 2018

same.

@Dkendal

This comment has been minimized.

Dkendal commented Jul 4, 2018

Also have been getting this, it only happens when declaration is set to true.

@ezolenko

This comment has been minimized.

Owner

ezolenko commented Jul 5, 2018

This is the same issue as #95, we'll track it there.

@ezolenko ezolenko closed this Jul 5, 2018

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