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

Unexpected token error when folder name contains parentheses #94

Closed
apptaro opened this issue Jun 29, 2018 · 2 comments
Closed

Unexpected token error when folder name contains parentheses #94

apptaro opened this issue Jun 29, 2018 · 2 comments
Labels
kind: bug Something isn't working properly problem: stale Issue has not been responded to in some time scope: dependencies Issues or PRs about updating a dependency scope: upstream Issue in upstream dependency solution: workaround available There is a workaround available for this issue

Comments

@apptaro
Copy link

apptaro commented Jun 29, 2018

What happens and why it is wrong

rollup -c results in a wrong Error: Unexpected token error when the project folder name contains parentheses like D:\Rollup(Test). Workaround is to remove parentheses from the project folder name like D:\RollupTest

Environment

  • Windows 10
  • Node 8.9.4

Versions

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

rollup.config.js

import typescript2 from 'rollup-plugin-typescript2';

export default {
    input: 'src/App.ts',
    output: {
        file: 'dist/Apps.js',
        format: 'amd'
    },
    plugins: [
        typescript2({
            clean: true,
            verbosity: 3
        })
    ]
}

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "es2015"
  }
}

package.json

{
  "name": "rolluptest",
  "version": "1.0.0",
  "devDependencies": {
    "rollup": "^0.62.0",
    "rollup-plugin-typescript2": "^0.15.1",
    "typescript": "^2.9.2"
  }
}

plugin output with verbosity 3

log:
D:\Rollup(Test)>node_modules\.bin\rollup -c

src/App.ts → dist/Apps.js...
rpt2: typescript version: 2.9.2
rpt2: tslib version: 1.9.2
rpt2: rollup-plugin-typescript2 version: 0.15.1
rpt2: plugin options:
{
    "clean": true,
    "verbosity": 3,
    "check": true,
    "cacheRoot": "D:\\Rollup(Test)/.rpt2_cache",
    "include": [
        "*.ts+(|x)",
        "**/*.ts+(|x)"
    ],
    "exclude": [
        "*.d.ts",
        "**/*.d.ts"
    ],
    "abortOnError": true,
    "rollupCommonJSResolveHack": false,
    "typescript": "version 2.9.2",
    "useTsconfigDeclarationDir": false,
    "tsconfigOverride": {},
    "transformers": [],
    "tsconfigDefaults": {}
}
rpt2: rollup config:
{
    "external": [
        "",
        ""
    ],
    "inlineDynamicImports": false,
    "input": "src/App.ts",
    "chunkGroupingSize": 5000,
    "perf": false,
    "plugins": [
        {
            "name": "rpt2"
        }
    ],
    "entry": "src/App.ts"
}
rpt2: built-in options overrides: {
    "noEmitHelpers": false,
    "importHelpers": true,
    "noResolve": false,
    "noEmit": false,
    "inlineSourceMap": false,
    "outDir": "D:\\Rollup(Test)/.rpt2_cache/placeholder",
    "moduleResolution": 2,
    "declarationDir": null
}
rpt2: parsed tsconfig: {
    "options": {
        "module": 5,
        "target": 1,
        "configFilePath": "D:/Rollup(Test)/tsconfig.json",
        "noEmitHelpers": false,
        "importHelpers": true,
        "noResolve": false,
        "noEmit": false,
        "inlineSourceMap": false,
        "outDir": "D:\\Rollup(Test)/.rpt2_cache/placeholder",
        "moduleResolution": 2,
        "declarationDir": null
    },
    "fileNames": [
        "D:/Rollup(Test)/src/App.ts"
    ],
    "typeAcquisition": {
        "enable": false,
        "include": [],
        "exclude": []
    },
    "raw": {
        "compilerOptions": {
            "module": "es2015",
            "target": "es5"
        }
    },
    "errors": [],
    "wildcardDirectories": {
        "d:/rollup(test)": 1
    },
    "compileOnSave": false,
    "configFileSpecs": {
        "includeSpecs": [
            "**/*"
        ],
        "validatedIncludeSpecs": [
            "**/*"
        ],
        "wildcardDirectories": {
            "d:/rollup(test)": 1
        }
    }
}
rpt2: included:
'[
    "*.ts+(|x)",
    "**/*.ts+(|x)"
]'
rpt2: excluded:
'[
    "*.d.ts",
    "**/*.d.ts"
]'
rpt2: Ambient types:
rpt2:     D:/Rollup(Test)/node_modules/@types/estree/index.d.ts
rpt2:     D:/Rollup(Test)/node_modules/@types/node/index.d.ts
rpt2: ambient types changed, redoing all semantic diagnostics
[!] Error: Unexpected token
src\App.ts (2:11)
1: export class App {
2:     public text: string = "a";
              ^
3:     constructor() {
4:     }


D:\Rollup(Test)>
@ezolenko ezolenko self-assigned this Jul 18, 2018
@ezolenko ezolenko added this to the 0.16.2 milestone Jul 18, 2018
@ezolenko ezolenko modified the milestones: 0.17.0, 0.17.1 Aug 28, 2018
@ezolenko ezolenko removed this from the 0.17.1 milestone Oct 16, 2018
@ezolenko ezolenko removed their assignment Dec 3, 2018
@agilgur5 agilgur5 added the solution: workaround available There is a workaround available for this issue label May 8, 2022
@agilgur5 agilgur5 changed the title Unexpected token error occurs when the project folder name contains parentheses Unexpected token error when folder name contains parentheses May 8, 2022
@agilgur5 agilgur5 added kind: support Asking for support with something or a specific use case solution: can't repro An attempt to reproduce has been tried and failed solution: out-of-scope This is out of scope for this project scope: upstream Issue in upstream dependency problem: stale Issue has not been responded to in some time and removed help wanted labels Jun 17, 2022
@agilgur5
Copy link
Collaborator

I created a minimal reproduction here and was unable to reproduce this error.

Neither tsc nor rpt2 seem to give this error in their latest versions (4.7.3 for TS, 0.32.1 for rpt2).

It's possible that this is a Windows-only error, and, unfortunately, I don't have a Windows repro environment to check that. Both this and a downstream issue linked here (PeculiarVentures/webcrypto-liner#71) are on Windows.

The downstream issue is newer and so has some nicer logging, and there the error is coming from Rollup itself, not from rpt2. So if this issue is reproducible on Windows, I would try it without rpt2 and just with raw Rollup, and see if it occurs again. If so, then this issue should be filed upstream in Rollup's repo

@agilgur5
Copy link
Collaborator

agilgur5 commented Jun 17, 2022

Correction, this seems to have been upstream in @rollup/pluginutils (not Rollup itself), who's createFilter function is responsible for filtering files for plugins.

It seems to have had a bug in it per rollup/plugins#80 where it interpreted parentheses as glob characters, and so filtered out the file from any plugin trying to read it. No plugin read it, so Rollup tries to read it, and then gives an error that this file is not JS and that plugins are needed to read it.
(in newer versions with better logging the full Rollup error is: Error: Unexpected token (Note that you need plugins to import files that are not JavaScript))

This bug was fixed upstream in rollup/plugins#84 (and some similar bugs in rollup/plugins#141) and released in @rollup/pluginutils v3.0.1+.
(A fix was also attempted earlier, but not merged, back in rollup/rollup-pluginutils#63)

rpt2 was updated to a compatible version in #219 (notably, same author that fixed that bug) and released in 0.27.0.

So rpt2 0.27.0+ should no longer have this bug.

@agilgur5 agilgur5 added kind: bug Something isn't working properly scope: dependencies Issues or PRs about updating a dependency and removed kind: support Asking for support with something or a specific use case solution: can't repro An attempt to reproduce has been tried and failed solution: out-of-scope This is out of scope for this project labels Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working properly problem: stale Issue has not been responded to in some time scope: dependencies Issues or PRs about updating a dependency scope: upstream Issue in upstream dependency solution: workaround available There is a workaround available for this issue
Projects
None yet
Development

No branches or pull requests

3 participants