Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESBuild plugin: Module not found #1

Open
Bios-Marcel opened this issue Sep 25, 2023 · 2 comments
Open

ESBuild plugin: Module not found #1

Bios-Marcel opened this issue Sep 25, 2023 · 2 comments

Comments

@Bios-Marcel
Copy link

Bios-Marcel commented Sep 25, 2023

Hey, I tried using the plugin, but I get the following:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'project/node_modules/unplugin-tdewolff-minify-html-literals/dist/esbuild.js' imported from project/scripts/build.js
    at new NodeError (node:internal/errors:405:5)
    at finalizeResolution (node:internal/modules/esm/resolve:224:11)
    at moduleResolve (node:internal/modules/esm/resolve:836:10)
    at defaultResolve (node:internal/modules/esm/resolve:1034:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:375:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:344:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:220:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:85:39)
    at link (node:internal/modules/esm/module_job:84:36) {
  url: URL {},
  code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v20.7.0

using the import line from the readme:

import minifyHTML from 'unplugin-tdewolff-minify-html-literals/esbuild';

After installation, the strucutre in my node_modules looks like this:

$ tree -L 2 node_modules/unplugin-tdewolff-minify-html-literals/
node_modules/unplugin-tdewolff-minify-html-literals/
├── dist
│   ├── index.cjs
│   ├── index.d.ts
│   ├── index.js
│   ├── rollup.cjs
│   ├── rollup.d.ts
│   ├── rollup.js
│   ├── rspack.cjs
│   ├── rspack.d.ts
│   ├── rspack.js
│   ├── types.d.ts
│   ├── utils
│   ├── vite.cjs
│   ├── vite.d.ts
│   ├── vite.js
│   ├── webpack.cjs
│   ├── webpack.d.ts
│   └── webpack.js
├── LICENSE
├── node_modules
│   ├── estree-walker
│   ├── @jridgewell
│   ├── magic-string
│   ├── @rollup
│   └── @types
├── package.json
└── README.md

9 directories, 19 files

Installation done via npm:

npm i -D unplugin-tdewolff-minify-html-literals @tdewolff/minify

Am i missing something?

To me it looks like the entry is missing: https://github.com/importantimport/unplugin-tdewolff-minify-html-literals/blob/main/vite.config.ts#L10

@kwaa
Copy link
Member

kwaa commented Sep 25, 2023

Hi, it looks like I'm missing the esbuild entry in the vite configuration.

But I'm considering ditching this plugin because I'm getting parsing errors when using it in my own projects...

My new attempt of minify-html-literals is at importantimport/literals, but that's not expected to be done soon (or ever).

Until then, I recommend that you use unplugin to wrap the original minify-html-literals if you need to.

@Bios-Marcel
Copy link
Author

Yeah, i fixed this manually in my node modules folder to see I was getting parsing issues as well 😅

I was looking for some ootb plugin to minify literals used for lit element. I guess you mean to just inline an unplugin call in my esbuild then, I will try that, thanks for the quick reply.

I'll keep an eye on your second attempt 😄 Have a nice day

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants