parcel: Parcel with source maps enabled cannot import LiveScript

πŸ› bug report

Parcel with source maps enabled cannot import LiveScript

πŸŽ› Configuration (.babelrc, package.json, cli command)

{
  "name": "livescript-parcel",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "parcel build index.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "livescript": "^1.6.0",
    "parcel-bundler": "^1.10.3"
  }
}

πŸ€” Expected Behavior

import livescript from 'livescript' should work

😯 Current Behavior

 > parcel build index.js

⚠️  Could not load existing sourcemap of "node_modules/livescript/lib/index.js".
🚨  livescript-parcel/node_modules/livescript/lib/index.js:69:43: Expecting Unicode escape sequence \uXXXX (69:43)
  67 |         if ((ref$ = options.map) === 'linked' || ref$ === 'debug') {
  68 |           mapPath = path.basename(outputFilename) + ".map";
> 69 |           result.code += "\n + mapPath + "\n";
     |                                           ^
  70 |         } else {
  71 |           result.code += "\n//# sourceMappingURL=data:application/json;base64," + bufferFrom(result.map.toString()).toString('base64') + "\n";
  72 |         }

It appears that parcel is incorrectly interpreting the file as a source map.

        if ((ref$ = options.map) === 'linked' || ref$ === 'debug') {
          mapPath = path.basename(outputFilename) + ".map";
          result.code += "\n//# sourceMappingURL=" + mapPath + "\n";
        } else {
          result.code += "\n//# sourceMappingURL=data:application/json;base64," + bufferFrom(result.map.toString()).toString('base64') + "\n";
        }

πŸ’» Code Sample

https://github.com/raine/livescript-parcel

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 5
  • Comments: 23 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Two fixes :

  • either remove \n from strings in the package sources (node_modules/paper/dist/paper-full.js in my case)
  • or disable source-maps: parcel index.html --no-source-maps

Is there a better solution?

This is still an issue with 1.x.

i’m sorry to say @DeMoorJasper but this is not fixed in 1.x versions. adding the --no-source-maps is a hack not a proper way to use it. can you please provide the PR or commit it for this fix?

Same issue with paper.js:

Arthur:3my4v Arthur$ parcel index.html 
Server running at http://localhost:1234 
⚠️  Could not load existing sourcemap of "node_modules/paper/dist/paper-full.js".
β ‹ Building css-loader.js...Browserslist: caniuse-lite is outdated. Please run next command `yarn upgrade`
Browserslist: caniuse-lite is outdated. Please run next command `yarn upgrade`
🚨  /Users/Arthur/Desktop/3my4v/node_modules/paper/dist/paper-full.js:17211:12: Unterminated string constant (17211:12)
  17209 | 			}
  17210 | 			if (/^(inline|both)$/.test(sourceMaps)) {
> 17211 | 				code += "\n
        | 				       ^
  17212 | 						+ self.btoa(unescape(encodeURIComponent(
  17213 | 							JSON.stringify(map))));
  17214 | 			}
⚠️  Could not load existing sourcemap of "node_modules/paper/dist/paper-full.js".

Ran into this issue with an imported React component that was bundled with webpack. Especially unfortunate because I had to use webpack to bundle that component in the first place because of https://github.com/parcel-bundler/parcel/issues/3305 On the plus side, the --no-source-maps is an acceptable workaround for me.

(I frigging love Parcel btw, I wish I could use it all the time for everything!)

Can we get a release cut with this fix before 2.0? We aren’t able to compile with source maps which is making debugging difficult. I’d like to avoid forking and cherry-picking the fix

This just bit me when importing vuejs-datepicker into my project. A temporary workaround was to use parcel with --no-source-maps, but I’m looking forward to the proper solution.

@DeMoorJasper I think I’ve encountered the same problem. Update to Parcel 2 worked for me. The code sample (https://github.com/raine/livescript-parcel) runs for me without build errors, when I use Parcel 2.

πŸ› Bug Report

Parcel with source maps enabled cannot import ckeditor5 Editor

πŸŽ› Configuration (.babelrc, package.json, cli command)

{
  "name": "parcel-ckeditor",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "parcel build index.js"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@ckeditor/ckeditor5-build-classic": "^20.0.0",
    "@ckeditor/ckeditor5-react": "^2.1.0",
    "parcel-bundler": "^1.12.4",
    "react": "^16.13.1",
    "react-dom": "^16.13.1"
  }
}

πŸ€” Expected Behavior

import ClassicEditor from '@ckeditor/ckeditor5-build-classic' should work

😯 Current Behavior

> parcel build index.js

⚠️  Could not load existing sourcemap of "node_modules/@ckeditor/ckeditor5-build-classic/build/ckeditor.js".
🚨  parcel-ckeditor/node_modules/@ckeditor/ckeditor5-build-classic/build/ckeditor.js:5:6589: Unexpected token (5:6589)
  3 |  * For licensing, see LICENSE.md.
  4 |  */
> 5 | !function(t){const e=t.en=t.en||{};e.dictionary=Object.assign(e.dictionary||{},{"%0 o ...

πŸ’ Possible Solution

Use Parcel 2

npm install -D parcel@next

🌍 Environment

Software Version(s)
Parcel 1.12.4
Node 14.4.0
npm 6.14.5

@medmin does it work in Parcel 2?

I think we fixed this.

Same issue with TypeScript.

The line in dependency:

sourceMap && (css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */");

have transformed to

sourceMap && (css += "\n + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */");

Part of the string and the quote was cut