{"id":16048926,"url":"https://github.com/devongovett/importer","last_synced_at":"2025-07-02T09:04:30.646Z","repository":{"id":2029893,"uuid":"2966368","full_name":"devongovett/importer","owner":"devongovett","description":"Deprecated: File importing for CoffeeScript and JavaScript","archived":false,"fork":false,"pushed_at":"2015-02-15T03:24:29.000Z","size":217,"stargazers_count":59,"open_issues_count":0,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-05T11:33:47.706Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devongovett.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-12-12T18:26:56.000Z","updated_at":"2024-09-08T22:26:50.000Z","dependencies_parsed_at":"2022-09-10T23:01:20.332Z","dependency_job_id":null,"html_url":"https://github.com/devongovett/importer","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/devongovett/importer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devongovett%2Fimporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devongovett%2Fimporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devongovett%2Fimporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devongovett%2Fimporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devongovett","download_url":"https://codeload.github.com/devongovett/importer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devongovett%2Fimporter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262539182,"owners_count":23325844,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-09T00:11:17.920Z","updated_at":"2025-07-02T09:04:30.622Z","avatar_url":"https://github.com/devongovett.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"**Deprecated:** I am no longer using or maintaining this library. Please use [Browserify](https://github.com/substack/node-browserify) instead.\n\nImporter\n========\n\nImporter adds an `#import` statement to JavaScript based languages including CoffeeScript that works like \n`#include` in C-based languages.  It compiles files into JavaScript, concatenates them together in the \nplaces you've defined, generates [source maps](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k), \nand manages recompilation for only those files that have changed, speeding up builds for large projects.\n\n```coffeescript\n#import \"name\"\n#import \"another.coffee\"\n#import \"somefile.js\"\n    \n# some code using the imported files here...\n```\n    \nIn JavaScript, the `//import` directive can be used instead of `#import`.  \n\n## Features\n\n* Import statements can be placed anywhere and the dependency source code will replace it.\n* Compiling CoffeeScript and JavaScript source files are included out of the box.  You can add more \n  to the `importer.extensions` object.\n* Support for generating [source maps](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k).\n* Support for framework or library dependencies in a search path as well as relative paths.\n* File extensions are optional and will be automatically resolved if not included.  \n* Files will only be included once in the resulting code, regardless of how many times a file is imported.\n* If used as a server, only modified files will be recompiled on subsequent requests.\n* Can be used to run the compiled code directly on the command line or `require`d in a Node module.\n  \n## Command line usage\n\nWhen installed with `npm install importer -g`, a command line tool called `importer` will be made available.\n\n1. To start a server to host your compiled code, run `importer mainfile.coffee --port 8080`\n2. To output to a file, run `importer mainfile.coffee main.js`\n3. To compile and execute, run `importer mainfile.coffee`\n\nThe command line options include:\n\n    -p, --port        Port to start server on       \n    -f, --frameworks  Path to frameworks directory    [default: \"./frameworks\"]\n    -m, --minify      Minifies the output JavaScript  [boolean]\n    -s, --source-map  Whether to output a source map  [boolean]\n\n## Node module usage\n\n```coffeescript\nimporter = require 'importer'\npkg = importer.createPackage './path/to/main/file',\n    frameworkPath: '/path/to/frameworks'\n    sync: false               # whether compilation should be synchronous (default: false)\n    sourceMap: 'out.js.map'   # filename/url of the output sourcemap (default: null)\n    minify: false             # whether to minify the output with UglifyJS\n        \n# if asynchronous...\npkg.build (err, result) -\u003e\n    # result is an object containing \n    # {code: 'compiled js', map: 'sourcemap if requested'}\n        \n# if synchronous...\ntry\n    result = pkg.build()\ncatch err\n    # do something\n        \n# to load and run the result as a node module...\nmoduleExports = pkg.require()\n\n# or, without creating a package\nmoduleExports = importer.require './path/to/main/file',\n    frameworkPath: '/path/to/frameworks'\n```\n\n## Connect/Express middleware\n\n```coffeescript\n# options supports all options documented above, plus the `url`\n# attribute giving the route to use to access the compiled JS.\n# Defaults to `\"/#{path.basename(main, path.extname(main))}.js\"`\n# Sourcemaps are automatically generated at \"#{url}.js.map\" unless\n# you turn them off by setting the `sourceMap` option to `false`.\napp.use importer.middleware('main.coffee', options)\n```\n    \n## Adding additional languages\n\nCurrently, importing CoffeeScript and JavaScript files are supported but you can extend that to other languages that compile to\nJavaScript by adding an entry to the `importer.extensions` object.\n\n```coffeescript\nimporter.extensions['.lua'] = (code, generateSourceMap) -\u003e \n    return lua.compile(code)\n```\n        \nIf a language compiler supporting source maps is used, you should first check the `generateSourceMap` option to be sure that\nthey are desired by the user, and if so, return an object containing `{code: 'compiled js', map: 'sourcemap'}`.  Otherwise, \nreturn a string.\n    \n## License\n\nThe `importer` module is licensed under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevongovett%2Fimporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevongovett%2Fimporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevongovett%2Fimporter/lists"}