Coder Social home page Coder Social logo

Comments (8)

jrburke avatar jrburke commented on June 2, 2024

Ah, well right now you would need to generate a separate build command for each script being targeted, since the name property would always be "almond.js" for each one.

I'm not sure how else to do it or if there would be something easier. The tricky part is that the name is the same for all of them since almond.js should be first in the output list.

from almond.

Integralist avatar Integralist commented on June 2, 2024

aha! okie dokie, I'll try it manually then and see how I get on.

I assume that getting this to work on multiple scripts is on the wish list, if not I'd definitely suggest it :-)

On a side note, I'm right in thinking that any calls to require() within the top-level require() still works with Almond, correct? It mentions what's supported on the README but I wasn't sure if it meant just top-level require() calls.

Thanks.

from almond.

Integralist avatar Integralist commented on June 2, 2024

I've received an error when trying to run the build script command (note: I've minified the Almond.js script - so I don't know if that would have any effect?)

The command I'm running is:

node r.js -o baseUrl=../ name=Almond.min.js include=main out=main-built.js wrap=true

If you look at my repo https://github.com/Integralist/RequireJs-Example/ you'll see that I'm cd'ing to the relevant path Assets/Scripts/Build/ so I can access r.js and from there I'm running the above command.

But I'm getting back the following error:

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
Error: Error evaluating module "undefined" at location "undefined":
Error: ERROR: module path does not exist: Almond.min.js for module named: Almond.min.js. Path is relative to: /Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/Assets/Scripts/Build
fileName:undefined
lineNumber: undefined
http://requirejs.org/docs/errors.html#defineerror
    at makeError (/Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/Assets/Scripts/Build/r.js:178:17)
    at execManager (/Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/Assets/Scripts/Build/r.js:594:23)
    at /Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/Assets/Scripts/Build/r.js:629:25
    at execManager (/Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/Assets/Scripts/Build/r.js:606:17)
    at /Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/Assets/Scripts/Build/r.js:629:25
    at execManager (/Users/stormcreative/Dropbox/Library/JavaScript/LibrarieMark-McDonnells-iMac:Build stormcreative$

It looks like it can't find the file: /Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/Assets/Scripts/Build/Almond.min.js

but if I change the command to:
node r.js -o baseUrl=../ name=../Almond.min.js include=main out=main-built.js wrap=true (notice the name flag has changed with the script going up a directory ../) I then get a similar error about the file:
Bad file descriptor '/Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/Assets/Scripts/../Almond.min.js'

Any idea on how to run this command based on my repo's current structure?

Thanks for your help.

Kind regards,
Mark

from almond.

jrburke avatar jrburke commented on June 2, 2024

Ah, so I believe it should be name=Almond.min if you want module ID lookup rules. Otherwise, with the .js it means it will look for it relative to perhaps the current directory.

Also, I was thinking more about this, if you wanted just one build file to run, you could create a node program and drive the optimizer multiple times in one script file. This example shows using requirejs as a module and calling requirejs.optimize().

That might be nice if you have a common set of paths you want to use for all the commands. You can specify them once then mix them in into a new config object for each call.

However, if you can just specify the build command via the command line a shell script might be simpler.

from almond.

Integralist avatar Integralist commented on June 2, 2024

@jrburke I've tried the command as you specified above but I now get a different error about not being able to locate jQuery...

Mark-McDonnells-iMac:Build stormcreative$ node r.js -o baseUrl=../ name=Almond.min include=main out=main-built.js wrap=true

Tracing dependencies for: Almond.min

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
Error: Error: Error evaluating module "undefined" at location "/Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/Assets/Scripts/jquery.js":
Error: EBADF, Bad file descriptor '/Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/Assets/Scripts/jquery.js'
fileName:/Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/Assets/Scripts/jquery.js
lineNumber: undefined
http://requirejs.org/docs/errors.html#defineerror
In module tree:
    main
      App/people

    at Function.onError (/Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/Assets/Scripts/Build/r.js:7653:23)
    at execManager (/Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/Assets/Scripts/Build/r.js:601:28)
    at /Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/Assets/Scripts/Build/r.js:629:25
    at execManager (/Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/Assets/Scripts/Build/r.js:606:17)
    at /Users/stormcreativeMark-McDonnells-iMac:Build stormcreative$ 

jquery is specified in 'main.js' as a named module path...

require.config({ 
    paths: { 
        jquery: 'Utils/jquery'
    } 
}); 

...but it seems that the command (when being executed) is trying to locate jquery here: Assets/Scripts/jquery.js rather than where it is which is Assets/Scripts/Utils/jquery.js? The script appears to error here: Assets/Scripts/App/people

from almond.

Integralist avatar Integralist commented on June 2, 2024

@jrburke I've just tried the command again but with a different script that wasn't using jquery...

node r.js -o baseUrl=../ name=Almond.min include=example-useful-modules out=example-useful-modules-built.js wrap=true

...but this gives a similar error where it can't find the modules when they are inside the Utils folder?

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
Error: Error: Error evaluating module "undefined" at location "/Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/Assets/Scripts/morpheus.js":
Error: EBADF, Bad file descriptor '/Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/Assets/Scripts/morpheus.js'
fileName:/Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/Assets/Scripts/morpheus.js
lineNumber: undefined
http://requirejs.org/docs/errors.html#defineerror
In module tree:
    example-useful-modules

    at Function.onError (/Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/Assets/Scripts/Build/r.js:7653:23)
    at execManager (/Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/Assets/Scripts/Build/r.js:601:28)
    at /Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/Assets/Scripts/Build/r.js:629:25
    at execManager (/Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/Assets/Scripts/Build/r.js:606:17)
    at /Users/stormcrMark-McDonnells-iMac:Build stormcreative$ 

from almond.

jrburke avatar jrburke commented on June 2, 2024

The build tool does not use the require.config() in the main.js file to get paths: configuration, it has to be set up in the build command/build profile. You can run the command line command as a build profile, just convert name=value command line args into name: 'value' properties in a build profile.

The optimizer explicitly avoids using the requirejs config from the main.js file because for a build the config would likely be different.

If I misunderstood the issue please let me know.

from almond.

Integralist avatar Integralist commented on June 2, 2024

Thanks for your help, I used the examples-useful-modules script to build from and so I removed the require.config/path set-up and manually specified the paths in the require() call and the build script completed without error. But then when inserting the build script into the page it was causing an error (I tried a few different variations to see if I could get it working but couldn't).

I'm going to close this issue now as it seems Almond isn't for me. I appreciate that it's a smaller footprint but it seems to cause too much disruption to my work-flow compared to how easily RequireJs works (set-up the build script and boom it's all taken care of).

Also (after minifying+gzip'ing) the size of RequireJs is only about 5k, and I can live with that :-)

Thanks again for your time trying to help me get this fixed.

from almond.

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.