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

Wrong detection of a sourcemap entry when it's just a string #3670

Closed
Symbiatch opened this issue Oct 24, 2019 · 5 comments
Closed

Wrong detection of a sourcemap entry when it's just a string #3670

Symbiatch opened this issue Oct 24, 2019 · 5 comments
Labels

Comments

@Symbiatch
Copy link

🐛 bug report

Parcel detects sourcemaps in JS files when they're inside JS code strings and aren't actually sourcemaps.

🎛 Configuration (.babelrc, package.json, cli command)

Parcel 1.12.4, vue-notification 1.3.16, no configurations otherwise

🤔 Expected Behavior

Parcel correctly bundles the code included in vue-notification like Webpack etc do

😯 Current Behavior

vue-notification has the following line in dist/index.js (don't know if it's normal that Parcel loads a dist/js file instead of going to the source, this line is from some dependency of vue-notification):

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

This causes Parcel to assume it's a sourcemap while it's actually just text inside a string in code that outputs sourcemaps. Error goes away if I break it up, for example

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

error message:

‼ Could not load existing sourcemap of "../../node_modules/vue-notification/dist/index.js".
‼ Could not load existing sourcemap of "../../node_modules/vue-notification/dist/index.js".
× ...\node_modules\vue-notification\dist\index.js:1070:83: Unterminated regular expression (1070:83)
1068 | css += '\n/*# sourceURL=' + sourceMap.sources[0] + ' */'
1069 | // http://stackoverflow.com/a/26603875

1070 | css += '\n + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + ' */'
| ^
1071 | }
1072 |
1073 | if (styleElement.styleSheet) {

💁 Possible Solution

🔦 Context

💻 Code Sample

import vue-notification in a project, run Parcel on it

🌍 Your Environment

Software Version(s)
Parcel 1.12.4
Node 12.6.0
npm/Yarn npm 6.10.2
Operating System Windows 10 Pro
@Symbiatch Symbiatch changed the title Wrong detection of a sourcemap entry Wrong detection of a sourcemap entry when it's just a string Oct 24, 2019
@DeMoorJasper
Copy link
Member

This has been fixed for Parcel 2, not entirely sure if we'll fix it for Parcel 1

@mischnic
Copy link
Member

(Duplicate of #2408)

@TimMensch
Copy link

On this one -- is there a workaround for the time until Parcel 2 is released? I just ran into this in another project (@json-editor/json-editor) where Parcel is choking on a source map string.

I'd try bumping my project to Parcel 2, but there doesn't appear to be a Parcel 2 release available on npm yet?

@devongovett
Copy link
Member

@TimMensch it's under the parcel name instead of parcel-bundler now. parcel@next should install it for you.

@TimMensch
Copy link

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants
@devongovett @TimMensch @DeMoorJasper @Symbiatch @mischnic and others