Code Monkey home page Code Monkey logo

Comments (13)

guybedford avatar guybedford commented on June 3, 2024

Actually I do have typescript installed as a global too, and am still getting this.

The actual error is GET file:///Users/guybedford/Projects/jspm-cli/sandbox/typescript/bin/lib.d.ts net::ERR_FILE_NOT_FOUND.

from plugin-typescript.

frankwallis avatar frankwallis commented on June 3, 2024

This is because when compiling it needs to fetch this declaration file which is shipped with the typescript compiler. I need to make a change so that it resolves it correctly, but until then you have to add an explicit mapping to the file - see #6

My mapping looks like this:

"typescript/bin/*.d.ts": "jspm_packages/npm/[email protected]/bin/*.d.ts",

from plugin-typescript.

guybedford avatar guybedford commented on June 3, 2024

You can call:

System.normalize('typescript', __moduleName)
.then(function(normalized){
  return System.locate({ name: normalized, metadata: {} });
}).then(function(pathToTypeScript) {
});

to access these paths through the loader API.

from plugin-typescript.

frankwallis avatar frankwallis commented on June 3, 2024

thanks, that's now fixed in 0.5.7.

from plugin-typescript.

frankwallis avatar frankwallis commented on June 3, 2024

Actually there is still an issue here - if the root project does not have typescript installed then the resolution fails.

It seems to be because __moduleName is set to http://localhost:8081/jspm_packages/github/frankwallis/[email protected]/lib/format-errors.js which is actually the module address. I've traced it through to here:

// Define our eval outside of the scope of any other reference defined in this
// file to avoid adding those references to the evaluation scope.
function __eval(__source, __global, load) {
  // Hijack System.register to set declare function
  var __curRegister = System.register;
  System.register = function(name, deps, declare) {
    if (typeof name != 'string') {
      declare = deps;
      deps = name;
    }
    // store the registered declaration as load.declare
    // store the deps as load.deps
    load.declare = declare;
    load.depsList = deps;
  }
  try {
    eval('(function() { var __moduleName = "' + (load.name || '').replace('"', '\"') + '"; ' + __source + ' \n }).call(__global);');
  }
  catch(e) {
    if (e.name == 'SyntaxError' || e.name == 'TypeError')
      e.message = 'Evaluating ' + (load.name || load.address) + '\n\t' + e.message;
    throw e;
  }

when it does the eval, load.name is correctly set to github:frankwallis/[email protected], but __source is set to this:

"var __moduleAddress = "http://localhost:8081/jspm_packages/github/frankwallis/[email protected]/lib/format-errors.js";System.register("http://localhost:8081/jspm_packages/github/frankwallis/[email protected]/lib/format-errors.js", ["typescript"], function($__export) {
  "use strict";
  var __moduleName = "http://localhost:8081/jspm_packages/github/frankwallis/[email protected]/lib/format-errors.js";
  var ts;
  function formatErrors(diags, logger) {
    /* MORE CODE */

so the good value of __moduleName gets overwritten by a bad value - coming from traceur by the look of it.

@guybedford - have you seen this before? Traceur is adding its own __moduleName variable to the transpiled source, and setting it to the module address.

from plugin-typescript.

guybedford avatar guybedford commented on June 3, 2024

@frankwallis thanks I've created ModuleLoader/es-module-loader#332.

from plugin-typescript.

guybedford avatar guybedford commented on June 3, 2024

@frankwallis what version of Traceur are you using here? We've definitely got this in the tests, so I'm not sure why it's failing for you (System.traceurOptions.moduleName = false should make sure Traceur doesn't set this).

from plugin-typescript.

guybedford avatar guybedford commented on June 3, 2024

@frankwallis is this specifically for builds?

from plugin-typescript.

frankwallis avatar frankwallis commented on June 3, 2024

@guybedford - I'll have to get back to you later about this - what do you mean by 'specifically for builds'?

from plugin-typescript.

guybedford avatar guybedford commented on June 3, 2024

Sure thanks, no rush. I meant as in if the error came up while running builds or in the browser. Because the in-browser case is very much tested - https://github.com/ModuleLoader/es6-module-loader/blob/master/test/loader/moduleName.js, also why I suggested ensuring Traceur is up to date.

from plugin-typescript.

frankwallis avatar frankwallis commented on June 3, 2024

It is happening in the browser, when compiling the plugin-typescript example project. What I am seeing is that with traceur 0.0.84 (default version from jspm) it fails as described above (even if I set moduleName: false), but when I manually update traceur to 0.0.87 then everything works as expected.

from plugin-typescript.

guybedford avatar guybedford commented on June 3, 2024

@frankwallis ok thanks. It sounds like this is due to that previous Traceur regression then, which should fix up in the next update.

from plugin-typescript.

frankwallis avatar frankwallis commented on June 3, 2024

this was resolved in jspm 0.15

from plugin-typescript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.