{"name":"@astrojs/compiler","version":"2.9.2","author":{"name":"withastro"},"license":"MIT","_id":"@astrojs/compiler@2.9.2","maintainers":[{"name":"natemoo-re","email":"nate@natemoo.re"},{"name":"fredkschott","email":"fkschott@gmail.com"},{"name":"matthewp","email":"matthew@matthewphillips.info"}],"homepage":"https://astro.build","bugs":{"url":"https://github.com/withastro/compiler/issues"},"dist":{"shasum":"c01dcdb14dc938758e66f9856934b83b6cd986d1","tarball":"http://registry-npm.ywwl.com/@astrojs/compiler/download/@astrojs/compiler-2.9.2.tgz","fileCount":40,"integrity":"sha512-Vpu0Ffsj8SoV+N0DFHlxxOMKHwSC9059Xy/OlG1t6uFYSoJXxkBC2WyF6igO7x10V+8uJrhOxaXr3nA90kJXow==","signatures":[{"sig":"MEUCIGo/ntE146tYAGdfhlP5zHeCFcW8Ek/OKpfCsGhJgE+UAiEAvW4pdLVecLtidIzhKUYYMKENsPtApc6PFpOeDpn5AZY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5214883,"size":1432455,"noattachment":false,"key":"/@astrojs/compiler/-/@astrojs/compiler-2.9.2.tgz"},"main":"./dist/node/index.js","type":"module","_from":"file:astrojs-compiler-2.9.2.tgz","types":"./dist/shared/types.d.ts","exports":{".":{"types":"./dist/node/index.d.ts","import":"./dist/node/index.js","browser":"./dist/browser/index.js","default":"./dist/browser/index.js","require":"./dist/node/index.cjs"},"./sync":{"types":"./dist/node/sync.d.ts","import":"./dist/node/sync.js","default":"./dist/node/sync.js","require":"./dist/node/sync.cjs"},"./types":"./dist/shared/types.d.ts","./utils":{"types":"./dist/node/utils.d.ts","import":"./dist/node/utils.js","browser":"./dist/browser/utils.js","default":"./dist/browser/utils.js","require":"./dist/node/utils.cjs"},"./astro.wasm":"./dist/astro.wasm","./package.json":"./package.json"},"scripts":{"build":"tsup"},"_npmUser":{"name":"fredkschott","email":"fkschott@gmail.com"},"_resolved":"/tmp/a57dacd8bfd23df193193f92b8222edd/astrojs-compiler-2.9.2.tgz","_integrity":"sha512-Vpu0Ffsj8SoV+N0DFHlxxOMKHwSC9059Xy/OlG1t6uFYSoJXxkBC2WyF6igO7x10V+8uJrhOxaXr3nA90kJXow==","repository":{"url":"git+https://github.com/withastro/compiler.git","type":"git"},"_npmVersion":"8.19.4","description":"Astro’s [Go](https://golang.org/) + WASM compiler.","directories":{},"_nodeVersion":"16.20.2","_hasShrinkwrap":false,"devDependencies":{"tsup":"^6.7.0","acorn":"^8.8.1","esbuild":"^0.17.17","typescript":"~5.0.2","@types/node":"^18.15.11","@types/sass":"^1.43.1","@jridgewell/trace-mapping":"^0.3.16"},"_npmOperationalInternal":{"tmp":"tmp/compiler_2.9.2_1721238611694_0.13008668536396284","host":"s3://npm-registry-packages"},"readme":"# Astro Compiler\n\nAstro’s [Go](https://golang.org/) + WASM compiler.\n\n## Install\n\n```\nnpm install @astrojs/compiler\n```\n\n## Usage\n\n#### Transform `.astro` to valid TypeScript\n\nThe Astro compiler can convert `.astro` syntax to a TypeScript Module whose default export generates HTML.\n\n**Some notes**...\n\n- TypeScript is valid `.astro` syntax! The output code may need an additional post-processing step to generate valid JavaScript.\n- `.astro` files rely on a server implementation exposed as `astro/runtime/server/index.js` in the Node ecosystem. Other runtimes currently need to bring their own rendering implementation and reference it via `internalURL`. This is a pain point we're looking into fixing.\n\n```js\nimport { transform, type TransformResult } from \"@astrojs/compiler\";\n\nconst result = await transform(source, {\n  filename: \"/Users/astro/Code/project/src/pages/index.astro\",\n  sourcemap: \"both\",\n  internalURL: \"astro/runtime/server/index.js\",\n});\n```\n\n#### Parse `.astro` and return an AST\n\nThe Astro compiler can emit an AST using the `parse` method.\n\n**Some notes**...\n\n- Position data is currently incomplete and in some cases incorrect. We're working on it!\n- A `TextNode` can represent both HTML `text` and JavaScript/TypeScript source code.\n- The `@astrojs/compiler/utils` entrypoint exposes `walk` and `walkAsync` functions that can be used to traverse the AST. It also exposes the `is` helper which can be used as guards to derive the proper types for each `node`.\n\n```js\nimport { parse } from \"@astrojs/compiler\";\nimport { walk, walkAsync, is } from \"@astrojs/compiler/utils\";\n\nconst result = await parse(source, {\n  position: false, // defaults to `true`\n});\n\nwalk(result.ast, (node) => {\n  // `tag` nodes are `element` | `custom-element` | `component`\n  if (is.tag(node)) {\n    console.log(node.name);\n  }\n});\n\nawait walkAsync(result.ast, async (node) => {\n  if (is.tag(node)) {\n    node.value = await expensiveCalculation(node)\n  }\n});\n```\n\n## Develop\n\n### VSCode / CodeSpaces\n\nA `devcontainer` configuration is available for use with VSCode's [Remote Development extension pack](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) and GitHub CodeSpaces.\n\n## Contributing\n\n[CONTRIBUTING.md](/CONTRIBUTING.md)\n","publish_time":1721238611866,"_cnpm_publish_time":1721238611866,"dist-tags":{"beta":"3.0.0-beta.1","canary":"0.1.0-canary.36","latest":"4.0.0","metadata-preview":"0.16.0-metadata-preview","next":"0.20.0-next.2","next--compact":"0.0.0-compact-20231220212312","next--dual":"0.0.0-dual-20230531170756","next--dynamic-slot-names":"0.0.0-dynamic-slot-names-20240111152903","next--err-jsx-comments-in-expr":"0.0.0-err-jsx-comments-in-expr-20231218110825","next--escaped-slash-tsx":"0.0.0-escaped-slash-tsx-20231227120419","next--fragment-in-tr-issue":"0.0.0-fragment-in-tr-issue-20231223214149","next--github-actions":"0.0.0-github-actions-20240228180311","next--head-body-content":"0.0.0-head-body-content-20240329184853","next--head-bubbling":"0.0.0-head-bubbling-20230216202235","next--head-metadata":"0.0.0-head-metadata-20230316175054","next--join-base":"0.0.0-join-base-20221208164627","next--jsx-attr-issue":"0.0.0-jsx-attr-issue-20231224202721","next--literal":"0.0.0-literal-20240329135330","next--literal-parsing":"0.0.0-literal-parsing-20240308150251","next--map-export":"0.0.0-map-export-20230418133923","next--mk-slot-expr-fix":"0.0.0-mk-slot-expr-fix-20240130083013","next--module-id":"0.0.0-module-id-20221205161912","next--namespaced-attribute-nospace":"0.0.0-namespaced-attribute-nospace-20230220235307","next--next-result-create-astro":"0.0.0-next-result-create-astro-20250926081949","next--no-panic":"0.0.0-no-panic-20231221205336","next--propagation-metadata":"0.0.0-propagation-metadata-20230907164537","next--render-script":"0.0.0-render-script-20251003120459","next--scopedStyleStrategy":"0.0.0-scopedStyleStrategy-20230501165917","next--script-order":"0.0.0-script-order-20251002140654","next--server-islands":"0.0.0-server-islands-20240620184241","next--set-directive-fix":"0.0.0-set-directive-fix-20230222151355","next--slot-pass":"0.0.0-slot-pass-20230206210453","next--slot-stream":"0.0.0-slot-stream-20230406193056","next--sourcemap":"0.0.0-sourcemap-20230103195910","next--sync":"0.0.0-sync-20230418131144","next--table-tr-expr-issue":"0.0.0-table-tr-expr-issue-20231223194846","next--teardown":"0.0.0-teardown-20230228094908","next--test-non-admin-snapshot":"0.0.0-test-non-admin-snapshot-20240308150815","next--transition-reload":"0.0.0-transition-reload-20240211162919","next--tsx-comments-whitespace":"0.0.0-tsx-comments-whitespace-20231228223836","next--tsx-prefix":"0.0.0-tsx-prefix-20231229054418","next--view-transitions":"0.0.0-view-transitions-20230731144215","next--wasm":"0.11.0-next--wasm.0","next--win":"0.0.0-win-20221104182719","next--windows":"0.0.0-windows-20221104181455","no-canonical":"0.19.0-pre.0","pre":"0.15.2-pre.0","render-head-pre":"0.17.0-pre.4","view-transitions":"1.7.0-pre.2"}}