{"id":20857572,"url":"https://github.com/openlayers/webpack-jsdoc-closure-loader","last_synced_at":"2026-04-25T10:33:40.868Z","repository":{"id":66035626,"uuid":"120118462","full_name":"openlayers/webpack-jsdoc-closure-loader","owner":"openlayers","description":"A webpack loader that converts JSDoc types from namepaths to types for Closure Compiler","archived":false,"fork":false,"pushed_at":"2018-02-05T21:36:36.000Z","size":12,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-12-26T21:54:11.908Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openlayers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-02-03T18:33:23.000Z","updated_at":"2023-12-17T02:20:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"197a4f57-7af1-4ce2-8964-a9464358e9ff","html_url":"https://github.com/openlayers/webpack-jsdoc-closure-loader","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/openlayers/webpack-jsdoc-closure-loader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openlayers%2Fwebpack-jsdoc-closure-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openlayers%2Fwebpack-jsdoc-closure-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openlayers%2Fwebpack-jsdoc-closure-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openlayers%2Fwebpack-jsdoc-closure-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openlayers","download_url":"https://codeload.github.com/openlayers/webpack-jsdoc-closure-loader/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openlayers%2Fwebpack-jsdoc-closure-loader/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32259472,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T09:15:33.318Z","status":"ssl_error","status_checked_at":"2026-04-25T09:15:31.997Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-11-18T04:41:10.288Z","updated_at":"2026-04-25T10:33:40.826Z","avatar_url":"https://github.com/openlayers.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# webpack-jsdoc-closure-loader\n\nA webpack loader that converts JSDoc types from [namepaths](http://usejsdoc.org/about-namepaths.html) with [module identifiers](http://usejsdoc.org/howto-commonjs-modules.html#module-identifiers) to  types for Closure Compiler.\n\nThis is useful for type checking and building a set of ES modules with Closure Compiler, e.g. through  the [webpack-closure-compiler](https://www.npmjs.com/package/webpack-closure-compiler) plugin.\n\n\n## Install\n\n    $ npm install --save-dev webpack-jsdoc-closure-loader\n\n\n## Configure webpack\n\nAdd the loader to the `modules` section of your webpack configuration:\n\n```js\nmodule: {\n  rules: [{\n    test: /\\.js$/,\n    loaders: ['webpack-jsdoc-closure-loader'],\n    exclude: /node_modules/\n  }]\n},\n```\n\n\n## Preparing your js source files\n\nEach file needs a `@module` JSDoc annotation with the path and name at the top of the file. If you have a file `src/foo/bar.js` and `src` is the package root, use the following annotation:\n\n```js\n/** @module foo/bar */\n```\n\n\n## Using types from a different module\n\nDefine the type using a JSDoc [module identifiers](http://usejsdoc.org/howto-commonjs-modules.html#module-identifiers), e.g.\n\n```js\n/** @type {module:foo/bar.mytype} */\nconst foo = {\n  bar: 'baz'\n};\n```\n\nThe type used above is defined in `src/foo/bar.js` like this:\n\n```js\n/** @typedef {{bar: string}} */\nexport let mytype;\n```\n\nor\n\n```js\n/** @typedef {{bar: string}} mytype */\n```\n\n\n## What the loader does\n\n### Inlining of `@typedef`s\n\nSince typedefs are just shorthands for complex types in Closure Compiler, they can be inlined wherever they are used. In the above example, the result that the compiler sees will be\n\n```js\n/** @type {{bar: string}} */\nconst foo = {\n  bar: 'baz'\n};\n```\n\n### Import types from module identifiers\n\nWhen bundling your application, webpack will import types from other files. Let's say you have a file `foo/Bar.js` with the following:\n\n```js\n/** @module foo/Bar */\n\n/**\n * @constructor\n * @param {string} name Name.\n */\nconst Bar = function(name) {\n  this.name = name;\n};\nexport default Person;\n```\n\nThen you can use this in another module with\n\n```js\n/**\n * @param {module:foo/Bar} bar Bar.\n */\nfunction foo(bar) {}\n```\n\nThe bundler will get something like\n\n```js\nconst foo$Bar = require('./foo/Bar');\n/**\n * @param {foo$Bar} bar Bar.\n */\nfunction foo(bar) {}\n```\n\nWith this, the type definition is made available to the module that uses the type.\n\n### Locally repeat `@enum`s\n\nClosure Compiler does not recognize imported enums, so these are repeated locally. If module `types` specifies\n\n```js\n/** @enum {number} */\nexport const Foo = {\n  BAR: 1,\n  BAZ: 2\n};\n```\n\nand another module uses\n\n```js\n/** @type {module:types.Foo} */\nconst foo;\n```\n\nthe bundler will get something like\n\n```js\n/** @enum {number} */ let _types_Foo = { BAR: 1, BAZ: 2 };\n_types_Foo = require('./types').Foo;\n/** @type {_types_Foo} */\nconst foo;\n```\n\nRepeating the enum locally and in addition requiring it helps the copiler understand the enum in cases where it is also imported locally by the source.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenlayers%2Fwebpack-jsdoc-closure-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenlayers%2Fwebpack-jsdoc-closure-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenlayers%2Fwebpack-jsdoc-closure-loader/lists"}