Package org.mozilla.javascript.commonjs.module.provider

Examples of org.mozilla.javascript.commonjs.module.provider.ModuleSource


    }

    public ModuleSource loadModule(URI uri) {
        InputStream stream = classLoader.getResourceAsStream("modules/" + uri.getPath().substring(1) + ".js");
        if (stream != null) {
            return new ModuleSource(new InputStreamReader(stream), null, uri, null, null);
        }
        return null;
    }
View Full Code Here


        Reader sourceReader = scriptSourceProvider.getScriptSource(fullUri);

        if (sourceReader == null) {
            return null;
        } else {
            return new ModuleSource(sourceReader, null, uri, base, validator);
        }
    }
View Full Code Here

   
    if (exports == null) {
      synchronized(Require.class) {
        exports = this.unresolvedModuleCache.get(cacheKey);
        if (exports == null) {
          ModuleSource moduleSource = this.loadModuleSource(cx, id, uri, base);
          if (moduleSource == null) {
            this.unresolvedModuleCache.put(cacheKey, missingModule);
          }
          else {
            exports = this.moduleCache.get(moduleSource.getUri());
           
            if (exports == null) {
              exports = this.loadModuleExports(cx, moduleSource, isMain);
            }
           
View Full Code Here

       
    }
   
    private ModuleSource loadModuleSource(Context cx, String moduleId, URI moduleUri, URI baseUri) throws Exception
    {
    final ModuleSource moduleSource = (moduleUri == null)
                ? moduleSourceProvider.loadSource(moduleId, paths, null)
                : moduleSourceProvider.loadSource(moduleUri, baseUri, null);
               
        return moduleSource;
    }
View Full Code Here

            if ( loadFromUri(path, path, null) == null ) {
                throw new RuntimeException("Cannot find module " + moduleId);
            }
        }

        final ModuleSource moduleSource = loadFromUri(
                path, path, validator);

        if (moduleSource != null) {
            return moduleSource;
        }
View Full Code Here

      moduleFile += ".js";
    }

    URI fileUri = new File(moduleFile).toURI();

    ModuleSource source = loadAsFile(fileUri);

    if(source != null) {
      return source;
    }
View Full Code Here

  private ModuleSource loadNodeModules(String moduleId) throws IOException {

    URI uri = getCurrentModuleURI();

    //URI uri = new File(".").toURI().resolve("");
    ModuleSource source = null;

    while(source == null && !uri.getPath().equals("/")) {
      URI nodeModulesUri = uri.resolve("node_modules/");

      source = loadAsFileOrDirectory(moduleId, nodeModulesUri);
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.commonjs.module.provider.ModuleSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.