developit / developit/microbundle
Error: Unexpected token when including a file with `declare namespace` in it.
- Lenguaje dominante
- JavaScript
- Estrellas
- 8.1k
- Forks
- 358
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
Hi microbundle team.
I'm trying to build a package, and I've needed to override some types since the types repo for the main dependency hasn't been updated.
I was on `0.14.x` before, but I updated to `0.15.1` and I still get this error.
```
$ microbundle --jsx React.createElement --tsconfig tsconfig.build.json
Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
at /Users/user/Documents/osd-react-renderer/packages/renderer/src/types/OpenSeadragonV5.d.ts:3:8
1: /* eslint-disable max-classes-per-file */
2:
3: declare namespace OpenSeadragon {
^
4: export function isFunction(obj: unknown): boolean;
```
I actually had two errors in this file. The first error said:
```
osd-react-renderer: (babel plugin) SyntaxError: /Users/user/Documents/osd-react-renderer/packages/renderer/src/types/OpenSeadragonV5.d.ts: Missing semicolon. (3:7)
osd-react-renderer: 1 | /* eslint-disable max-classes-per-file */
osd-react-renderer: 2 |
osd-react-renderer: > 3 | declare namespace OpenSeadragon {
osd-react-renderer: | ^
osd-react-renderer: 4 | export function isFunction(obj: unknown): boolean;
osd-react-renderer: 5 |
osd-react-renderer: 6 | export function isCanvasTainted(canvas: HTMLCanvasElement): boolean;
osd-react-renderer: at undefined:3:7
```
This error I was able to resolve with a `.babelrc.json` file, but I can't see what configuration can be used to resolve the first error.
I noticed that previously we were able to build the app when we used `declare module `OpenSeadragonV2`, but `declare namespace` specifically is causing this.
Any suggestions on what configuration can resolve this issue?
Thanks
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Reproduce el comando reportado, `microbundle --jsx React.createElement --tsconfig tsconfig.build.json`, utilizando el archivo `OpenSeadragonV5.d.ts` referenciado. Empieza inspeccionando `tsconfig.build.json` y `.babelrc.json` para ver cómo se analizan los archivos de declaración y `declare namespace`. Se considera terminado cuando el paquete se compila sin los errores de sintaxis de Babel o de token inesperado.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- babel, javascript, typescript
- Área
- build-system, tooling
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100