Stillat / blade-parser-typescript

A Laravel Blade parser, compiler, and static analyzer written in TypeScript.
https://stillat.com
MIT License
90 stars 3 forks source link

Issue with missing dependencies for the "stillat-blade-parser" package #30

Closed yaegassy closed 1 year ago

yaegassy commented 1 year ago

Description

I have installed stillat-blade-parser and I'm using it for parsing purposes.

I believe there are missing dependencies in the stillat-blade-parser package.

To execute the sample code in the README, you will need to install additional packages such as prettier, php-parser, @prettier/plugin-php, @stedi/prettier-plugin-jsonata and jsonata in addition to the stillat-blade-parser package.

Repro

1. Prepare

mkdir -p /tmp/blade-parser-check
cd /tmp/blade-parser-check
npm init -y
npm i stillat-blade-parser
npm i -D typescript
npx tsc --init
touch sample.ts

2. Code

The following is an example code of using a simple parser described in the README.

sample.ts:

import { BladeDocument } from "stillat-blade-parser/out/document/bladeDocument";

const document = BladeDocument.fromText(`<html>
    <head>
        <title>{{ $title }}</title>
    </head>
</html>`);

3. When transpiling and running, I encounter an error.

npx tsc 

node sample.js

To resolve this, you need to install packages such as prettier, php-parser, @prettier/plugin-php, @stedi/prettier-plugin-jsonata and jsonata...

Error:

$ node sample.js
node:internal/modules/cjs/loader:1078
  throw err;
  ^

Error: Cannot find module 'prettier'
Require stack:
- /private/tmp/blade-parser-check/node_modules/stillat-blade-parser/out/formatting/prettier/utils.js
- /private/tmp/blade-parser-check/node_modules/stillat-blade-parser/out/document/printers/directivePrinter.js
- /private/tmp/blade-parser-check/node_modules/stillat-blade-parser/out/document/transformer.js
- /private/tmp/blade-parser-check/node_modules/stillat-blade-parser/out/document/bladeDocument.js
- /private/tmp/blade-parser-check/sample.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
    at Module._load (node:internal/modules/cjs/loader:920:27)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (/private/tmp/blade-parser-check/node_modules/stillat-blade-parser/out/formatting/prettier/utils.js:30:36)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Module.require (node:internal/modules/cjs/loader:1141:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/private/tmp/blade-parser-check/node_modules/stillat-blade-parser/out/formatting/prettier/utils.js',
    '/private/tmp/blade-parser-check/node_modules/stillat-blade-parser/out/document/printers/directivePrinter.js',
    '/private/tmp/blade-parser-check/node_modules/stillat-blade-parser/out/document/transformer.js',
    '/private/tmp/blade-parser-check/node_modules/stillat-blade-parser/out/document/bladeDocument.js',
    '/private/tmp/blade-parser-check/sample.js'
  ]
}

Node.js v18.16.0
JohnathonKoster commented 1 year ago

Sorry about that! I've pushed a 1.1.9 release with the update dependencies list πŸ™Œ

yaegassy commented 1 year ago

Thanks πŸ™‡ @JohnathonKoster

yaegassy commented 1 year ago

@JohnathonKoster Your active development on the blade parser (typescript and php) is truly remarkable. Thanks. πŸ™‡

This is unrelated to the issue at hand, but are you familiar with something called tree-sitter?

There are tree-sitters available for Twig and Django HTML (Python related), but unfortunately, there is currently no tree-sitter specifically designed for Blade...

If you were to develop tree-sitter-blade, I believe it would become something truly remarkable. If you're interested, I suggest looking into tree-sitter.