-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add prepare script, making it easy to install Prism from outside of NPM. #3699
base: v2
Are you sure you want to change the base?
Conversation
The `prepare` script is the NPM-standard way in which outside-of-NPM packages can be build, for example with installed from a git location. After merging this into the main branch (currently `master`), people will be able to do this: ```sh npm install prismjs@github:PrismJS/prism ``` If they want to try it right now before v2 is merged (if this is merged into v2), they can do this: ```sh npm install prismjs@github:PrismJS/prism#v2 ``` Without this, such installations are not possible. What NPM does during the `install` process is - it clones the specified repo, - checks out the specified git ref (f.e. `v2`), - installs dependencies including dev dependencies, - runs the `prepare` script if any (the `prepare` script will *always* have dev dependencies available to it), - and finally packages the result in the same way as `npm pack` such that build outputs are included in the final package that gets installed into the user's node_modules This would be a way for people to easily test v2 right now and provide feedback.
By the way, now that I've made this pull request, I can install and test this like so: npm install prismjs@github:trusktr/prism#patch-1 I'll see if this currently works, and will update if not. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @trusktr -- were you able to confirm this works for you? I'm happy to ✅
Will take it for a spin soon. I'm ironing out a few PRs in Docsify first, namely one PR to convert to |
@JaKXz Here's an example that installs Prism from git, and then imports and initializes a https://github.com/trusktr/prism-v2-test There's no syntax highlighting, and the docs aren't updated to describe how to use v2 yet, so I'm not yet sure how to get syntax coloring to be applied. The build output also doesn't have type declaration outputs yet, so there wasn't yet intellisense or type checking in VS Code when I imported Prism. It guesses from the plain JS output: Happy to help iron these details out. I also think at this point in time we don't need to ship legacy CommonJS. To avoid maintenance, I'd say let other people build to CommonJS if they need to, f.e. they can use Rollup for that, and we can otherwise support the ES Module reality that all JS engines and build tools support nowadays. But TLDR: the git install works! We can merge this if you'd like, and then work out the other details separately. |
This PR's commit is now included in |
The
prepare
script is the NPM-standard way in which outside-of-NPM packages can be build, for example with installed from a git location.After merging this into the main branch (currently
master
), people will be able to do this:If they want to try it right now before v2 is merged (if this is merged into v2), they can do this:
Without this, such installations are not possible.
What NPM does during the
install
process isv2
in#v2
),prepare
script if any (theprepare
script will always have dev dependencies available to it),npm pack
such that build outputs are included in the final package that gets installed into the user's node_modulesThis would be a way for people to easily test v2 right now and provide feedback.