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

no such file or directory, open '.../assets/dag-map.js.map' #29

Closed
stevenwu opened this issue Oct 3, 2017 · 27 comments
Closed

no such file or directory, open '.../assets/dag-map.js.map' #29

stevenwu opened this issue Oct 3, 2017 · 27 comments

Comments

@stevenwu
Copy link

stevenwu commented Oct 3, 2017

I installed and setup for the first time.

Build Canceled: Broccoli Builder ran into an error with UglifyWriter plugin. 💥
ENOENT: no such file or directory, open '/Users/steve/projects/marais/ui/tmp/uglify_writer-input_base_path-4C6JkBvo.tmp/assets/dag-map.js.map'
Error: ENOENT: no such file or directory, open '/Users/steve/projects/marais/ui/tmp/uglify_writer-input_base_path-4C6JkBvo.tmp/assets/dag-map.js.map'
@boris-petrov
Copy link

I have the same problem. Didn't happen with 2.0.0-beta.2.

@Turbo87
Copy link
Member

Turbo87 commented Oct 4, 2017

@stevenwu can you reproduce with a fresh ember new app? what steps are necessary?

@Turbo87 Turbo87 changed the title Unable to start dev server no such file or directory, open '.../assets/dag-map.js.map' Oct 4, 2017
@Turbo87
Copy link
Member

Turbo87 commented Oct 4, 2017

this was likely caused by updating https://github.com/lydell/source-map-url from 0.3.0 to 0.4.0, which I assume surfaced other issues in the libs that we're trying to minify. in other words: I don't think this is an issue with Uglify itself but rather in some lib that isn't distributing its sourcemap properly 🤔

problem now is figuring out where dag-map.js comes from and why the dag-map.js.map file is missing even though it is probably announced to be available in dag-map.js.

@rwjblue
Copy link
Member

rwjblue commented Oct 4, 2017

dag-map is most likely krisselden/dag-map, but I don’t know why it would be manually concatted to the output (it isn’t part of a default ember-cli app)...

@Turbo87
Copy link
Member

Turbo87 commented Oct 4, 2017

Not sure if it helps but I've hit this issue too now. With our app at Ember 2.12 everything builds as expected, but if I then upgrade the app to Ember 2.16 (both via bower, not npm) it fails with that error during prod build.

@rwjblue
Copy link
Member

rwjblue commented Oct 4, 2017

Ember internally uses dag-map perhaps it is including a sourcemap comment referencing the external file?

@stevenwu
Copy link
Author

stevenwu commented Oct 4, 2017

Yeah, I think the issue is sourcemap and one of the addons in my project.

@akatz
Copy link

akatz commented Oct 5, 2017

It also only seems to hit if you build in prod mode.

@Turbo87
Copy link
Member

Turbo87 commented Oct 5, 2017

It seems that this depends on the Ember version that you're running on. emberjs/ember.js#15577 aimed to fix a similar issue, but it is not clear yet whether that fix also works for this issue here and in which Ember versions it was included.

@rwjblue
Copy link
Member

rwjblue commented Oct 6, 2017

@Turbo87 - do you happen to know if this can be reproduced on a new app?

@Turbo87
Copy link
Member

Turbo87 commented Oct 9, 2017

do you happen to know if this can be reproduced on a new app?

I've just tried to reproduce this with a clean ember new app, but I'm not able to reproduce. Since this seems to work alright I don't think we should block the CLI release on it.

@boris-petrov
Copy link

boris-petrov commented Oct 9, 2017

@Turbo87, @rwjblue - here is a reproduction:

https://github.com/boris-petrov/ember-cli-uglify-issue

I did an ember new, use ember from bower (not sure if this matters) and added some of my packages in package.json (not sure which of those matter). If you run ember build --environment=production - it blows up. If you remove the sourcemaps property in ember-cli-build.js - it works fine.

I hope this is enough for you to debug it. Please tell me if I can help more.

@Turbo87
Copy link
Member

Turbo87 commented Oct 9, 2017

@boris-petrov awesome, thanks. I think ember from bower might be the issue, because that is what I remember doing too when I had that issue... 🤔

while this is certainly a valid issue, it is 1) an issue in Ember.js, not ember-cli-uglify and 2) an issue with Ember via bower which is no longer the default. so for those that have this issue you will have to stay on the old ember-cli-uglify version until this is resolved in Ember.js itself or migrate to using Ember via the ember-source npm dependency.

@boris-petrov
Copy link

@Turbo87 - I'm not sure what you mean that it is a problem in Ember.js. I've narrowed it down to broccoli-uglify-sourcemap's usage of source-map-url - if I downgrade manually in package-lock.json the version of only that package from 0.4.0 to 0.3.0 and leave everything else as is (including ember-cli-uglify at 2.0.0) - it works fine.

@Turbo87
Copy link
Member

Turbo87 commented Oct 9, 2017

@boris-petrov the problem is that source-map-url@0.4.0 fixed a bug, which uncovered another bug in how Ember.js is packaged up. So instead of reverting to source-map-url@0.3.0 the proper solution is to fix the Ember.js packaging.

@boris-petrov
Copy link

I see. Ok, thanks, I'll be waiting for a fix then. Should I expect one soon or is this a low priority for you now?

@Turbo87
Copy link
Member

Turbo87 commented Oct 9, 2017

Should I expect one soon or is this a low priority for you now?

I'm not that involved with the Ember.js bundling process and got a few other things to wrap up first. Feel free to have a look :)

@akatz
Copy link

akatz commented Oct 9, 2017

I'm working on an app that has migrated to ember-source and I can reproduce the error.

@akatz
Copy link

akatz commented Oct 9, 2017

I have changed my package.json file to try and track down when this started happening. This is what I found, changing only the ember-source dependency. ( If you want the full yarn.lock file for each change let me know)
does not happen on 2.13.4
does happen on 2.14.0
does happen on 2.15.2
does happen on 2.16.0-beta.1

@rwjblue
Copy link
Member

rwjblue commented Oct 9, 2017

OK, so it is not related to bower, but also ember-source

@rwjblue
Copy link
Member

rwjblue commented Oct 9, 2017

I need to understand the bug that was fixed in source-map-url to know why this is wrong.

If you take a look at [ember-source's source](https://unpkg.com/ember-source@2.14.0/dist/ember.debug.js) you can see that we do have `//# sourceMappingURL=dag-map.js.map` in the output (for `dag-map` module).
enifed("dag-map", ["exports"], function (exports) {
    "use strict";

    /**
     * A topologically ordered map of key/value pairs with a simple API for adding constraints.
     *
     * Edges can forward reference keys that have not been added yet (the forward reference will
     * map the key to undefined).
     */
    var DAG = function () {
        function DAG() {
            this._vertices = new Vertices();
        }
        /**
         * Adds a key/value pair with dependencies on other key/value pairs.
         *
         * @public
         * @param key    The key of the vertex to be added.
         * @param value  The value of that vertex.
         * @param before A key or array of keys of the vertices that must
         *               be visited before this vertex.
         * @param after  An string or array of strings with the keys of the
         *               vertices that must be after this vertex is visited.
         */
        DAG.prototype.add = function (key, value, before, after) {
            if (!key) throw new Error('argument `key` is required');
            var vertices = this._vertices;
            var v = vertices.add(key);
            v.val = value;
            if (before) {
                if (typeof before === "string") {
                    vertices.addEdge(v, vertices.add(before));
                } else {
                    for (var i = 0; i < before.length; i++) {
                        vertices.addEdge(v, vertices.add(before[i]));
                    }
                }
            }
            if (after) {
                if (typeof after === "string") {
                    vertices.addEdge(vertices.add(after), v);
                } else {
                    for (var i = 0; i < after.length; i++) {
                        vertices.addEdge(vertices.add(after[i]), v);
                    }
                }
            }
        };
        /**
         * @deprecated please use add.
         */
        DAG.prototype.addEdges = function (key, value, before, after) {
            this.add(key, value, before, after);
        };
        /**
         * Visits key/value pairs in topological order.
         *
         * @public
         * @param callback The function to be invoked with each key/value.
         */
        DAG.prototype.each = function (callback) {
            this._vertices.walk(callback);
        };
        /**
         * @deprecated please use each.
         */
        DAG.prototype.topsort = function (callback) {
            this.each(callback);
        };
        return DAG;
    }();
    exports.default = DAG;

    /** @private */
    var Vertices = function () {
        function Vertices() {
            this.length = 0;
            this.stack = new IntStack();
            this.path = new IntStack();
            this.result = new IntStack();
        }
        Vertices.prototype.add = function (key) {
            if (!key) throw new Error("missing key");
            var l = this.length | 0;
            var vertex;
            for (var i = 0; i < l; i++) {
                vertex = this[i];
                if (vertex.key === key) return vertex;
            }
            this.length = l + 1;
            return this[l] = {
                idx: l,
                key: key,
                val: undefined,
                out: false,
                flag: false,
                length: 0
            };
        };
        Vertices.prototype.addEdge = function (v, w) {
            this.check(v, w.key);
            var l = w.length | 0;
            for (var i = 0; i < l; i++) {
                if (w[i] === v.idx) return;
            }
            w.length = l + 1;
            w[l] = v.idx;
            v.out = true;
        };
        Vertices.prototype.walk = function (cb) {
            this.reset();
            for (var i = 0; i < this.length; i++) {
                var vertex = this[i];
                if (vertex.out) continue;
                this.visit(vertex, "");
            }
            this.each(this.result, cb);
        };
        Vertices.prototype.check = function (v, w) {
            if (v.key === w) {
                throw new Error("cycle detected: " + w + " <- " + w);
            }
            // quick check
            if (v.length === 0) return;
            // shallow check
            for (var i = 0; i < v.length; i++) {
                var key = this[v[i]].key;
                if (key === w) {
                    throw new Error("cycle detected: " + w + " <- " + v.key + " <- " + w);
                }
            }
            // deep check
            this.reset();
            this.visit(v, w);
            if (this.path.length > 0) {
                var msg_1 = "cycle detected: " + w;
                this.each(this.path, function (key) {
                    msg_1 += " <- " + key;
                });
                throw new Error(msg_1);
            }
        };
        Vertices.prototype.reset = function () {
            this.stack.length = 0;
            this.path.length = 0;
            this.result.length = 0;
            for (var i = 0, l = this.length; i < l; i++) {
                this[i].flag = false;
            }
        };
        Vertices.prototype.visit = function (start, search) {
            var _a = this,
                stack = _a.stack,
                path = _a.path,
                result = _a.result;
            stack.push(start.idx);
            while (stack.length) {
                var index = stack.pop() | 0;
                if (index >= 0) {
                    // enter
                    var vertex = this[index];
                    if (vertex.flag) continue;
                    vertex.flag = true;
                    path.push(index);
                    if (search === vertex.key) break;
                    // push exit
                    stack.push(~index);
                    this.pushIncoming(vertex);
                } else {
                    // exit
                    path.pop();
                    result.push(~index);
                }
            }
        };
        Vertices.prototype.pushIncoming = function (incomming) {
            var stack = this.stack;
            for (var i = incomming.length - 1; i >= 0; i--) {
                var index = incomming[i];
                if (!this[index].flag) {
                    stack.push(index);
                }
            }
        };
        Vertices.prototype.each = function (indices, cb) {
            for (var i = 0, l = indices.length; i < l; i++) {
                var vertex = this[indices[i]];
                cb(vertex.key, vertex.val);
            }
        };
        return Vertices;
    }();
    /** @private */
    var IntStack = function () {
        function IntStack() {
            this.length = 0;
        }
        IntStack.prototype.push = function (n) {
            this[this.length++] = n | 0;
        };
        IntStack.prototype.pop = function () {
            return this[--this.length] | 0;
        };
        return IntStack;
    }();
    //# sourceMappingURL=dag-map.js.map
});

A few things strike me here:
  1. I thought sourceMappingURL was only valid as the last line of a file?
  2. We likely don't actually include a dag-map.js.map in the vendor tree from ember-source (I'd have to double check)

I suppose for now, we can just strip the comment to squelch this error...

@Turbo87
Copy link
Member

Turbo87 commented Oct 9, 2017

I thought sourceMappingURL was only valid as the last line of a file?

apparently not, or at least that was the "bug" that was fixed in source-map-url@0.4.0

I suppose for now, we can just strip the comment to squelch this error...

that would be my recommendation too

rwjblue added a commit to rwjblue/ember.js that referenced this issue Oct 10, 2017
Babel is not properly ingesting the sourcemaps (even when the upstream
funnel brings the mapping file in with it), this commit strips it out to
avoid errors during uglification (reported in
ember-cli/ember-cli-terser#29).
rwjblue added a commit to emberjs/ember.js that referenced this issue Oct 10, 2017
Babel is not properly ingesting the sourcemaps (even when the upstream
funnel brings the mapping file in with it), this commit strips it out to
avoid errors during uglification (reported in
ember-cli/ember-cli-terser#29).

(cherry picked from commit 90da108)
@Turbo87
Copy link
Member

Turbo87 commented Oct 10, 2017

awesome, thank you @rwjblue!

@boris-petrov
Copy link

@Turbo87, @rwjblue - do you still need the repo with the reproduction or I can delete it?

@Turbo87
Copy link
Member

Turbo87 commented Oct 11, 2017

@boris-petrov no longer needed, now that emberjs/ember.js#15720 is merged. thanks! :)

@urbany
Copy link

urbany commented Oct 12, 2017

Hey everyone, I'm having a similar issue with the addon ember-popper.
Everything worked in ember-cli-uglify@1.2.0, but in ember-cli-uglify@2.0.0 I get an error.
It only occurs when I build for production with sourcemaps enabled: ember build -e production

Build failed.
The Broccoli Plugin: [Fingerprint] failed with:
Error: ENOENT: no such file or directory, open '/.../my-project/tmp/uglify_writer-input_base_path-K803YqEY.tmp/assets/popper.js.map'

ember-popper seems to be exporting the popper.js.map file:
https://github.com/kybishop/ember-popper/blob/v0.6.4/index.js#L22

And popper.js has this:

//# sourceMappingURL=popper.js.map

You can test with this repo: https://github.com/urbany/ember-popper-sourcemaps-error
ember build -e production

EDIT:
After a closer look I can see that in /.../my-project/tmp/uglify_writer-input_base_path-K803YqEY.tmp/assets/vendor.js still has this: //# sourceMappingURL=popper.js.map, this should probably be stripped sinde the popper.js.mapis already concatenated in the vendor.map

toddjordan pushed a commit to toddjordan/ember.js that referenced this issue Oct 13, 2017
Babel is not properly ingesting the sourcemaps (even when the upstream
funnel brings the mapping file in with it), this commit strips it out to
avoid errors during uglification (reported in
ember-cli/ember-cli-terser#29).
@maxvoltage
Copy link

maxvoltage commented Jan 4, 2018

I encountered this issue with swiper module, which has sourceMappingURL at the end of its minified js file in its dist folder. Will the solution be removing sourceMappingURL comment from it? Should I do the same for any other module I encounter to have a correct vendor.js.map?
I am on ember-source 2.16.2
also reproducible in 2.18

I opened a PR with broccoli-uglify-sourcemap. vendor.js file can have multiple sourceMappingURL locations when modules have their own sourceMappingURL. source-map-url module finds only one sourceMappingURL at a time. This PR removes sourceMappingURL if it doesn't have the same name with the js file until it finds the correct one.

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

No branches or pull requests

7 participants