Coder Social home page Coder Social logo

not working with text plugin about cajon HOT 9 CLOSED

requirejs avatar requirejs commented on July 19, 2024
not working with text plugin

from cajon.

Comments (9)

jrburke avatar jrburke commented on July 19, 2024

@jiggliemon can you provide more context on how that require('') call is done? Is it inside a module, or at the top level, outside a module? If outside a module, then I expect it to fail, since the loader can only find dependencies of that type inside a module.

from cajon.

jiggliemon avatar jiggliemon commented on July 19, 2024

@jrburke
This is essentially my simple setup:
https://gist.github.com/3208730 && https://github.com/jiggliemon/yayo/tree/master/www

Since you can load other modules in the sync fashion, I would expect to be able to also load files with a plugin dependency in the same style.

Are my expectations incorrect?

from cajon.

jrburke avatar jrburke commented on July 19, 2024

Yes, this should work, and I confirmed with a simple test locally, however, my config is done before the loading of simple, and I was not using package config. Based on the config in the gist, the template file should be at 'js/tmpl/simple.tmpl'. If it is not, and it should be inside the simple package, then using 'text!./tmpl/simple.tmpl' should work better.

You can check the network tab in the browser developer tools to see what path was used to try to fetch the template. I am suspecting the issue is related to that.

from cajon.

jiggliemon avatar jiggliemon commented on July 19, 2024

@jrburke You can see the directory structure here:
https://github.com/jiggliemon/yayo/tree/master/www

the template file is sitting in js/tmpl/simple.tmpl

What i found interesting from monitoring the network tab, was that the text.js plugin never loaded, also there's no attempt to request the template. See the network tab here:
http://cl.ly/image/3F3A3d1y3G2X

from cajon.

jrburke avatar jrburke commented on July 19, 2024

Ah, so this was a weakness in how cajon was constructed -- the config call and its fetch for deps happens before cajon's requirejs.load method was set up, so the old requirejs one was used by mistake. I just did a fix and pushed 0.0.4 with the fix.

from cajon.

jrburke avatar jrburke commented on July 19, 2024

Once this problem was fixed, I noticed another load problem, but due to the packages config. in requirejs, the default "main" is assumed to be a "main.js", but at least one of your packages uses "index.js", so you will need to configure the package's main property to be main: 'index' for it to work:

http://requirejs.org/docs/api.html#packages

from cajon.

jiggliemon avatar jiggliemon commented on July 19, 2024

I hadn't pushed my changes to the dependencies yet. However I usually put in a main.js file with the following:
define(['./index'],function (o) { return o })

Im not sure if this is related to the fix you implemented for 0.0.4, or just presenting itself since the template is now working. But the module config isn't working: http://requirejs.org/docs/api.html#config-moduleconfig
As seen being attempted here: https://github.com/jiggliemon/yate/blob/master/src/index.js#L4

I should prob open another issue?

from cajon.

jiggliemon avatar jiggliemon commented on July 19, 2024

Here's the error for attempting to use require('module'):
Module Error

from cajon.

jrburke avatar jrburke commented on July 19, 2024

Looks like require('module') is a generic issue in requirejs. I filed this issue to track that:

requirejs/requirejs#409

In this case though, it is simple enough to just use var config = module.config() since module is one of the default variables available for a module in cajon.

from cajon.

Related Issues (15)

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.