gren-lang / compiler

Compiler for the Gren programming language
https://gren-lang.org
Other
342 stars 21 forks source link

Sourcemaps don't include submodules #260

Closed mbartlett21 closed 2 weeks ago

mbartlett21 commented 3 weeks ago

Generating sourcemaps at the end with --sourcemaps doesn't include sourcemaps for modules that include a . in the name. For example, this is the (partial) decoded sourcemap for a project of mine:

Details

```json { "version": 3, "sources": [ "Dict", "Array", "Set", "Basics", "String", "Json.Encode", "Json.Decode", "Char", "Result", "VirtualDom", "Url", "Task", "Platform", "Browser", "Search", "Platform.Cmd", "Platform.Sub", "Url.Builder", "Maybe", "Http", "Process", "Html", "Html.Attributes", "Html.Events" ], "sourcesContent": [ "module Dict exposing\n ( Dict\n , e...", "module Array exposing\n ( Array\n ,...", "module Set exposing\n ( Set\n , emp...", "module Basics exposing\n ( Int, (+), (...", "module String exposing\n ( String, isE...", null, null, "module Char exposing\n ( Char\n , i...", "module Result exposing\n ( Result(..)\n..", "module VirtualDom exposing\n ( Node\n ,...", "module Url exposing\n ( Url\n , Protoco...", "effect module Task where { command = MyCm...", "module Platform exposing\n ( Program, ...", "module Browser exposing\n ( sandbox\n ...", "port module Search exposing (..)\n\nimpor...", null, null, null, "module Maybe exposing\n ( Maybe(..)\n ...", "effect module Http where { command = MyCm...", "module Process exposing (Id, spawn, sleep...", "module Html exposing\n ( Html, Attribute...", null, null ] } ```

robinheghan commented 3 weeks ago

Control question: you're certain that functions/constants from these modules are being referenced in the compiled JS? Code removed with dead-code elimination will not be source-mapped.

mbartlett21 commented 3 weeks ago

Yes, It was Json.Decode where I first noticed it. I ran into it when trying to debug where a Json.Decode was failing and the source just showed Could not load content for http://localhost:15732/scripts/Json.Decode (HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE)

image