Closed Kikobeats closed 3 years ago
Why do we need to export this path? Couldn't somebody that needs the path just do require.resolve('prism-themes/themes')
? It's not like we plan to rename the themes
folder anytime soon (since that would be a breaking change).
@RunDevelopment that was my initial assumption and it's failing:
https://github.com/microlinkhq/browserless/blob/master/packages/screenshot/src/pretty/theme.js#L9
The assumption is wrong since the folder is going to live depending on where npm install decides to place the folder, meaning that if the project has other dependencies using prism-themes it will be placed in a place where both dependencies can find it, making the path unpredictable.
The solution is to use "main" on package.json
to point to the dependency path, and because the dependency path is calculated using __dirname
, you always will have the absolute path!
@Kikobeats Not path.resolve
but require.resolve
.
@RunDevelopment require.resolve
can't find the module since the package doesn't have the "main"
field
require
wants to find .js
files, right... my bad. A main module is necessary in that case.
fixed lint issues!
added missing semicolon
I understand although literally I just added 5 lines of javascript to make possible use it like the rest of npm dependencies
@RunDevelopment any status of this? really want to use the library ðŸ˜
Sorry for the delay @Kikobeats. Let's merge this.
@RunDevelopment thanks a lot! can you please release a new version?
Just published a new version @Kikobeats.
Hello,
In a previous PR (#114) the
main
field atpackage.json
was removed because it was causing not useful.This PR adds the field again but rather than pointing to a filesystem folder, it's returning the absolute path where the themes are living:
This is actually useful because for some bundle workflow you need the reference of the folder to copy or load the themes.
In this way, it prevents copy the whole folder, but you still have a reference to the folder path in case you need it.