Open Robbert opened 8 years ago
We could build one big js file based on the current module and all dependencies, downside would be that any warning or error would reference the code line in the combined file, not the actual file.
Ideally we would use the AMD option of Closure Compiler to load all dependencies of the tested module, but so far we have not been able to use this successfully. Other people seem to be able to though....
Another option would be to build the AMD modules with RequireJS for example, and build source maps too, and convert the line number/column locations of any warnings from the Closure Compiler output back to the original files.
I have tried using r.js
to build the AMD modules. It is an addition to require.js
to build modules in different non-browser environments. The reason there is no default Gulp plugin is rumored to be that r.js
does all the filesystem handling itself, and is hard to combine with streaming build systems like Gulp.
So, how hard can it be to extend r.js
to support this use case? I am quite put off to this dirty work, because the code is really gross. The Node.js implementation can be found in a file called [x.js
], which I don't seem to be able to find in any git repo anymore.
So I dropped the require.js approach in favour of using an old build of my own AMD loader implementation. This worked great, although it required one workaround: create a new Loader
instance for every file.
Now that we have a stream for every .js
file in the src/
directory, the next step is building every compiled AMD module with Closure Compiler. The google-closure-compiler
package should do this, however it appears to aggregate all streams and build them as one. Now I need to tweak the package to have an option to build every file separately.
The only module currently in the repository is
URI.js
, which has no dependencies. New modules, that are likely to have dependencies, will fail linting (especially for the Closure Compiler) because of undefined dependencies. Before we can continue adding modules we need to be able to build the dependencies.--transform_amd_modules
flag for the Closure Compiler another try. Malte Ubl wrote this plugin in December 2011, not sure how much work has been done since...