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

[DO-NOT-MERGE] Add Nunjucks #69

Closed
wants to merge 2 commits into from
Closed

Conversation

lourot
Copy link
Contributor

@lourot lourot commented Sep 2, 2023

@magne4000 I'm stuck on this one. As part of a future bigger PR in which I add the Vue boilerplate, I'm trying to make use of nunjucks. This fails with

+ node packages/cli/dist/index.js --vue ../bati-output

 ERROR  Dynamic require of "events" is not supported

  at packages/cli/dist/boilerplates/@batijs/shared/files/$index.html.js:13:9
  at ../../../node_modules/.pnpm/nunjucks@3.2.4/node_modules/nunjucks/src/object.js (packages/cli/dist/boilerplates/@batijs/shared/files/$index.html.js:994:24)
  at __require2 (packages/cli/dist/boilerplates/@batijs/shared/files/$index.html.js:16:50)
  at ../../../node_modules/.pnpm/nunjucks@3.2.4/node_modules/nunjucks/src/nodes.js (packages/cli/dist/boilerplates/@batijs/shared/files/$index.html.js:1135:21)
  at __require2 (packages/cli/dist/boilerplates/@batijs/shared/files/$index.html.js:16:50)
  at ../../../node_modules/.pnpm/nunjucks@3.2.4/node_modules/nunjucks/src/parser.js (packages/cli/dist/boilerplates/@batijs/shared/files/$index.html.js:1487:18)
  at __require2 (packages/cli/dist/boilerplates/@batijs/shared/files/$index.html.js:16:50)
  at ../../../node_modules/.pnpm/nunjucks@3.2.4/node_modules/nunjucks/src/compiler.js (packages/cli/dist/boilerplates/@batijs/shared/files/$index.html.js:2904:19)
  at __require2 (packages/cli/dist/boilerplates/@batijs/shared/files/$index.html.js:16:50)
  at ../../../node_modules/.pnpm/nunjucks@3.2.4/node_modules/nunjucks/src/environment.js (packages/cli/dist/boilerplates/@batijs/shared/files/$index.html.js:10005:20)



 ERROR  Dynamic require of "events" is not supported

I understand that nunjucks is CommonJS and it probably does a require("events"), but I can't find how to solve this. I have tried to fiddle a bit more with core/rollup.config.js and tsup/index.ts, by adding nunjucks to these lists, but I just ended up hitting other problems and the search space is too big for me. Do you know more precisely how to fix this? Should events be added to a list somewhere?

Or is this the reason why you have created a magicast.ts that re-exports everything from magicast? Should I do the same for nunjucks? Thanks!

Failing with

+ node packages/cli/dist/index.js --vue ../bati-output

 ERROR  Dynamic require of "events" is not supported                                                                                                                                                                      4:43:20 PM

  at packages/cli/dist/boilerplates/@batijs/shared/files/$index.html.js:13:9
  at ../../../node_modules/.pnpm/nunjucks@3.2.4/node_modules/nunjucks/src/object.js (packages/cli/dist/boilerplates/@batijs/shared/files/$index.html.js:994:24)
  at __require2 (packages/cli/dist/boilerplates/@batijs/shared/files/$index.html.js:16:50)
  at ../../../node_modules/.pnpm/nunjucks@3.2.4/node_modules/nunjucks/src/nodes.js (packages/cli/dist/boilerplates/@batijs/shared/files/$index.html.js:1135:21)
  at __require2 (packages/cli/dist/boilerplates/@batijs/shared/files/$index.html.js:16:50)
  at ../../../node_modules/.pnpm/nunjucks@3.2.4/node_modules/nunjucks/src/parser.js (packages/cli/dist/boilerplates/@batijs/shared/files/$index.html.js:1487:18)
  at __require2 (packages/cli/dist/boilerplates/@batijs/shared/files/$index.html.js:16:50)
  at ../../../node_modules/.pnpm/nunjucks@3.2.4/node_modules/nunjucks/src/compiler.js (packages/cli/dist/boilerplates/@batijs/shared/files/$index.html.js:2904:19)
  at __require2 (packages/cli/dist/boilerplates/@batijs/shared/files/$index.html.js:16:50)
  at ../../../node_modules/.pnpm/nunjucks@3.2.4/node_modules/nunjucks/src/environment.js (packages/cli/dist/boilerplates/@batijs/shared/files/$index.html.js:10005:20)



 ERROR  Dynamic require of "events" is not supported
@magne4000
Copy link
Member

magne4000 commented Sep 3, 2023

Urgh, that's a shame.
I somewhat could fix that like I did for putout I think, but adding nunjucks to the core build adds 2.7MB to the bundle size, that a total no go.

FYI, external in packages/core/rollup.config.js are for putout because esbuild can't properly treeshake the code, and is not aware that we do not use those dependencies.
The goal of the core lib is to bundle all dependencies in a unique file, but for that we need proper libs that can be correctly bundled.

Alternatives

@lourot
Copy link
Contributor Author

lourot commented Sep 3, 2023

Thanks a lot @magne4000 🙏 All clear. I'll try out SquirellyJS

@lourot lourot closed this Sep 3, 2023
@lourot lourot deleted the aurelien/nunjucks branch September 3, 2023 10:22
@lourot lourot changed the title [NO-NOT-MERGE] Add Nunjucks [DO-NOT-MERGE] Add Nunjucks Sep 3, 2023
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

Successfully merging this pull request may close these issues.

None yet

2 participants