question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Module parse failed on tiff/lib-esm/tiffDecoder.js

See original GitHub issue

Hello,

I am trying to use image-js with ESM from an Angular application. I get the following error:

ERROR in ../node_modules/tiff/lib-esm/tiffDecoder.js 13:12
2021-10-11T22:10:54.877685815Z Module parse failed: Unexpected token (13:12)
2021-10-11T22:10:54.877688343Z You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
2021-10-11T22:10:54.877690795Z | };
2021-10-11T22:10:54.877693407Z | export default class TIFFDecoder extends IOBuffer {
2021-10-11T22:10:54.877695648Z >     _nextIFD;
2021-10-11T22:10:54.877697974Z |     constructor(data) {
2021-10-11T22:10:54.877700254Z |         super(data);

If I take a look at tiff/lib-esm/tiffDecoder.js, I see:

import { decompressZlib } from './zlib';
const defaultOptions = {
    ignoreImageData: false,
    onlyFirst: false,
};
export default class TIFFDecoder extends IOBuffer {
    _nextIFD;
    constructor(data) {
        super(data);
        this._nextIFD = 0;
    }
//...

_nextIFD declaration is not supported by the bundler.

This is the config used by tiff library:

rhousni@rhousni:~/projects/tiff$ tsc --showConfig --project tsconfig.esm.json
{
    "compilerOptions": {
        "esModuleInterop": true,
        "moduleResolution": "node",
        "sourceMap": true,
        "strict": true,
        "target": "esnext",
        "module": "es6",
        "outDir": "./lib-esm",
        "declaration": false
    },
    "files": [
        "./src/horizontalDifferencing.ts",
        "./src/ifd.ts",
        "./src/ifdValue.ts",
        "./src/index.ts",
        "./src/lzw.ts",
        "./src/tiffDecoder.ts",
        "./src/tiffIfd.ts",
        "./src/types.ts",
        "./src/zlib.ts",
        "./src/tags/exif.ts",
        "./src/tags/gps.ts",
        "./src/tags/standard.ts"
    ],
    "include": [
        "./src/**/*"
    ],
    "exclude": [
        "./src/**/__tests__"
    ]
}

So I guess JS class variable declaration is only supported in a future ECMAScript version.

Changing the TS target to es2017 fixes the issue. Would you accept a PR for this?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
targoscommented, Oct 12, 2021

It should be fine now.

1reaction
targoscommented, Oct 12, 2021

Thanks, I’m working on it 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module parse failed: You may need an appropriate loader to ...
I have an existing project (with custom webpack.config.dev.js file) that I want to integrate with storybooks but after following the getting ...
Read more >
Module parse failed: Unexpected character '@ in "webpack"
I was getting the same error twice, then I tried Webpack Module parse failed with bootstrap css and one error goes away. but...
Read more >
Odyssey Lift-off I: "Module parse failed: Unexpected token" Error
I am receiving this error message: Failed to compile. ./src/pages/tracks.js 43:10. Module parse failed: Unexpected token (43:10)
Read more >
Module parse failed: Unexpected token Emberjs - Build Issues
I currently have an issue in an addon which I'm trying to convert to an Emberjs addon to the V2 version. It's a...
Read more >
Module parse failed: Identifier 'e' has already been declared
That's typically a configuration issue with your framework/bundler and not an issue with the ArcGIS JS API. I'm basing my guess on one...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found