Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

.map sourcemap files missing from npm releases #2942

Closed
diuming opened this issue Jun 16, 2018 · 4 comments
Closed

.map sourcemap files missing from npm releases #2942

diuming opened this issue Jun 16, 2018 · 4 comments
Labels

Comments

@diuming
Copy link

diuming commented Jun 16, 2018

I'm a newbie with web technology?
The MDL is easy to use, but it's no longer to update.
The MDC-web is difficult for me and I can't find a step by step manual for general web server.
I always get errors when I run the code in general web server(like apache or nginx not for Nodejs).
Do I need to install nodjs, npm and webpack?
errors: (sorry: I don't have any experience with MDC-Web)


Cannot find module /dist/material-components-web.js.map in package [email protected]
Cannot find module /dist/material-components-web.js.map in package [email protected]

the code

<!DOCTYPE html>
<html>
    <head>
        <title>Material Components for the web-Drawer</title>
        <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
        <link rel="stylesheet" href="https://unpkg.com/material-components-web@latest/dist/material-components-web.min.css">
        <script src="https://unpkg.com/material-components-web@latest/dist/material-components-web.js"></script>
    </head>
    <body>
        <div>Toolbar goes here</div>
            <div class="content">
                <nav class="mdc-drawer mdc-drawer--permanent mdc-typography">
                    <nav id="icon-with-text-demo" class="mdc-list">
                        <a class="mdc-list-item mdc-list-item--activated" href="#">
                            <i class="material-icons mdc-list-item__graphic" aria-hidden="true">inbox</i>Inbox
                        </a>
                        <a class="mdc-list-item" href="#">
                            <i class="material-icons mdc-list-item__graphic" aria-hidden="true">star</i>Star
                        </a>
                    </nav>
            </nav>
            <main>
                Page content goes here.
            </main>
        </div>
    </body>
</html>
@diuming diuming changed the title WDC example and how with Apache server Does it possible to use MDC-web like MDL with general web server? Jun 18, 2018
@material-components material-components deleted a comment from matsp Jun 18, 2018
@kfranqueiro
Copy link
Contributor

kfranqueiro commented Jun 18, 2018

This error is occurring because we don't include the .map files within our npm releases. I'm a bit surprised though, since I don't actually see this error in Chrome at all... I do see an error reported in Firefox, though.

This is mostly harmless, since the .map file is only used for debugging. There shouldn't be anything special you need to do server-side in order to use MDC Web, regardless of what web server you use.

However, it might be worth us considering including the .map files in each npm release. The only foreseeable downside is increased burden on bandwidth when first installing a new version of MDC Web packages via npm.

@kfranqueiro kfranqueiro changed the title Does it possible to use MDC-web like MDL with general web server? .map files missing from npm releases Jun 18, 2018
@kfranqueiro kfranqueiro changed the title .map files missing from npm releases .map sourcemap files missing from npm releases Jul 18, 2018
@pavelsevcik
Copy link
Contributor

Dear @kfranqueiro,

can you either

A) include .map files in npm packages

or

B) disable map generation in prod build

reason is, that current setup where

is

devtool: 'source-map',

and

Promise.all(globSync('build/*.{css,js}').map(cpAsset)).catch((err) => {

is

Promise.all(globSync('build/*.{css,js}').map(cpAsset)).catch((err) => {

causing, that generated minified files ends with sourceMappingURL

/*# sourceMappingURL=mdc.drawer.min.css.map*/

but those files are not present in packages.

But that is causing for example build warnings when we use mdc with aurelia-cli

Error: An error occurred while trying to read the map file at /data/com__app/node_modules/@material/drawer/dist/mdc.drawer.js.map
Error: ENOENT: no such file or directory, open '/data/com__app/node_modules/@material/drawer/dist/mdc.drawer.js.map'
    at readFromFileMap (/data/com__app/node_modules/aurelia-cli/lib/build/convert-source-map/index.js:32:11)
    at new Converter (/data/com__app/node_modules/aurelia-cli/lib/build/convert-source-map/index.js:39:32)
    at Object.exports.fromMapFileComment (/data/com__app/node_modules/aurelia-cli/lib/build/convert-source-map/index.js:112:10)
    at Object.exports.fromMapFileSource (/data/com__app/node_modules/aurelia-cli/lib/build/convert-source-map/index.js:131:22)
    at acquireSourceMapForDependency (/data/com__app/node_modules/aurelia-cli/lib/build/bundle.js:200:33)
    at work.then (/data/com__app/node_modules/aurelia-cli/lib/build/bundle.js:222:25)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:229:7)

it's just warning, but because we include mdc packages one by one we get tons of those warnings and that make aurelia-cli output bloated with noise and as that hard to read.

appreciate your time and efford required to solve this cosmetic issue

Pavel

@pndewit
Copy link
Contributor

pndewit commented Dec 20, 2018

Having the same issue @pavelsevcik .. 😞

@pavelsevcik
Copy link
Contributor

@pndewit, I just submitted PR to add missing source-map files to npm releases

in meantime, try this quick and dirty hack of aurelia-cli in node_modules in your project (if you have aurelia-cli installed globaly hack code in global location)

add to <your-project-path>/node_modules/aurelia-cli/lib/build/bundle.js just right bellow first if in acquireSourceMapForDependency

  function acquireSourceMapForDependency(file) {
    if (!file || !file.path) {
      return;
    }

this quick and dirty hack to exclude @material packages source-map acquiring

    // WARNING: Hack / Workaround to supress Error: An error occurred while trying to read the map file
    if (/node_modules\/@material/.test(file.path)) return;

code gonna look like

function acquireSourceMapForDependency(file) {
    if (!file || !file.path) {
      return;
    }
    // WARNING: Hack / Workaround to supress Error: An error occurred while trying to read the map file
    if (/node_modules\/@material/.test(file.path)) return;

cheers

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

No branches or pull requests

4 participants