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

SystemJS 0.18 new baseURL behavior #77

Closed
metamatt opened this issue Jul 23, 2015 · 14 comments · Fixed by #84
Closed

SystemJS 0.18 new baseURL behavior #77

metamatt opened this issue Jul 23, 2015 · 14 comments · Fixed by #84

Comments

@metamatt
Copy link

SystemJS 0.18.0 enforces that baseURL can only be set before other config, and thus karma-jspm's call to System.config({ baseURL: 'base' }) provokes an error like

Chrome 44.0.2403 (Mac OS X 10.10.4) ERROR
  Uncaught TypeError: baseURL should only be configured once and must be configured first.
  at jspm_packages/system.src.js:1389
@metamatt
Copy link
Author

Here's a patch that works for my project. It does 3 things:

  1. swap the order of loading adapter.js (which sets baseURL to match karma's webserver's /base path) and the client project's config.js

  2. remove the separate import of es6-module-loader.js, which is now folded into system.js

  3. remove the code to remove the .js suffix from module IDs before calling System.import

diff --git a/node_modules/karma-jspm/src/adapter.js b/node_modules/karma-jspm/src/adapter.js
index 3200a9f..64f3eaa 100644
--- a/node_modules/karma-jspm/src/adapter.js
+++ b/node_modules/karma-jspm/src/adapter.js
@@ -19,10 +19,6 @@
     // Prevent immediately starting tests.
     window.__karma__.loaded = function() {};

-    function extractModuleName(fileName){
-        return fileName.replace(/\.js$/, "");
-    }
-
     var promises = [];

     if(!System){
@@ -46,7 +42,7 @@
     // Load everything specified in loadFiles
     for (var i = 0; i < karma.config.jspm.expandedFiles.length; i++) {
         var modulePath = karma.config.jspm.expandedFiles[i];
-        var promise = System['import'](extractModuleName(modulePath))
+        var promise = System['import'](modulePath)
             ['catch'](function(e){
                 setTimeout(function() {
                     throw e;
diff --git a/node_modules/karma-jspm/src/init.js b/node_modules/karma-jspm/src/init.js
index cda239e..8a77de7 100644
--- a/node_modules/karma-jspm/src/init.js
+++ b/node_modules/karma-jspm/src/init.js
@@ -92,10 +92,9 @@ module.exports = function(files, basePath, jspm, client) {
       return packagesPath + fileName + '.js';
     }
   }
-  files.unshift(createPattern(__dirname + '/adapter.js'));
   files.unshift(createPattern(configPath));
+  files.unshift(createPattern(__dirname + '/adapter.js'));
   files.unshift(createPattern(getLoaderPath('system')));
-  files.unshift(createPattern(getLoaderPath('es6-module-loader')));

   // Loop through all of jspm.load_files and do two things
   // 1. Add all the files as "served" files to the files array

@ghost
Copy link

ghost commented Jul 31, 2015

@metamatt can you make a PR to robertbaker/karma-jspm?

@zewa666
Copy link
Contributor

zewa666 commented Aug 7, 2015

this fix works for the 1.* branch, but I hadn't luck applying it to the current master/beta branches

@wwselleck
Copy link

Updating to 2.0.1-beta.1fixed the baseURL issues for me, but now is giving me different errors that I believe are coming from it adding 'dist' in this path Uncaught Error: XHR error (404 Not Found) loading /Users/weston/Desktop/aur-fork/www/dist/src/app.js. My karma.conf.js looks like this

    jspm: {
      // Edit this to your needs
      loadFiles: ['src/**/*.js', 'test/unit/**/*.js'],
      paths: {
        '*': '*.js'
      }
    },

and my System.js config includes

 paths: {
    "*": "dist/*",
    "github:*": "jspm_packages/github/*",
    "npm:*": "jspm_packages/npm/*"
  },

So I guess it's adding in the dist to my path because of the System config? (excuse my ignorance, fairly new to Karma and JSPM/System.js.)

@togakangaroo
Copy link

hitting this issue as well - similar issues to wwseleck

@Vheissu
Copy link

Vheissu commented Aug 12, 2015

Same issue as @wwseleck the value "dist" is getting added to my path. I would have thought in jarma.conf.js setting a path override under jspm: {} would have fixed this issue, but it seems the path overrides are ignored.

@JeroenVinke
Copy link
Contributor

#84 fixes this issue for me. You can test by using "karma-jspm": "git://github.com/JeroenVinke/karma-jspm#master", in your package.json and running npm install

@riddla
Copy link

riddla commented Aug 12, 2015

Thanks, the master branch fixed this problem for me.

@andrewflierman
Copy link

At this moment I'm running with SystemJS v0.19.4 and karma-jspm 2.0.1 I'm still getting the baseURL error:

Chrome 45.0.2454 (Windows 10 0.0.0) ERROR
Uncaught TypeError: baseURL should only be configured once and must be configured first.
at c:/Development/Projects/testApplication/src/Web/wwwroot/jspm_packages/system.src.js:1633

UPDATE: jspm/jspm-cli#1191

@alexcastillo
Copy link
Contributor

+1

@justinrassier
Copy link

This is happening to me as well. SystemJS v0.19.4 and karma-jspm 2.0.1 I found that if I comment out System.config({ baseURL: 'base' }); on line 18 of adapter.js, I am able to get my tests to run.

@togakangaroo
Copy link

Confirmed, this is back now.

@JockVanDallas
Copy link

Same error here

@andrewflierman
Copy link

It should be fixed in v0.19.5: systemjs/systemjs#837

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

Successfully merging a pull request may close this issue.