Skip to content
This repository has been archived by the owner on Jul 28, 2024. It is now read-only.

feat: make compatible with deno 1.7 #48

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,27 @@ labels: bug
assignees: ""
---

**Describe the bug**
A clear and concise description of what the bug is.
**Describe the bug** A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
**To Reproduce** Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.
**Expected behavior** A clear and concise description of what you expected to
happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.
**Screenshots** If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**

- OS: [e.g. macOS, Ubuntu, ...]
- Deno version [e.g. v1.3.0]
- denopack version [e.g. 0.10.0]

**Additional context**
Add any other context about the problem here.
**Additional context** Add any other context about the problem here.

**Checklist**

Expand Down
16 changes: 8 additions & 8 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Is your feature request related to a problem? Please describe.** A clear and
concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe the solution you'd like** A clear and concise description of what you
want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Describe alternatives you've considered** A clear and concise description of
any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
**Additional context** Add any other context or screenshots about the feature
request here.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup latest deno version
uses: denolib/setup-deno@v2
with:
deno-version: v1.4.4
deno-version: v1.7.0
jeiea marked this conversation as resolved.
Show resolved Hide resolved

- name: Format
run: deno fmt --check
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
"deno.lint": true,
"editor.formatOnSave": true,
"editor.defaultFormatter": "denoland.vscode-deno",
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
}
39 changes: 26 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.10.0](https://github.com/denofn/denopack/compare/0.9.1..0.10.0) - 2020-10-05

Expand Down Expand Up @@ -61,7 +62,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Switched out custom filter function in cssBundle for official Rollup createFilter function
- Switched out custom filter function in cssBundle for official Rollup
createFilter function

## [0.6.0](https://github.com/denofn/denopack/compare/0.5.0..0.6.0) - 2020-08-18

Expand All @@ -82,36 +84,47 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Directory loading to support dynamic imports and code splitting
- BREAKING: pluginTerserTransform is now an actual transform plugin, not an output plugin
- Sourcemapping identifiers are now appended in CLI, not in pluginTerserTransform
- BREAKING: pluginTerserTransform is now an actual transform plugin, not an
output plugin
- Sourcemapping identifiers are now appended in CLI, not in
pluginTerserTransform

## [0.4.0](https://github.com/denofn/denopack/compare/0.3.2..0.4.0) - 2020-08-11

### Added

- Handle entry file redirects (re: [denoland/deno/issues/3082](https://github.com/denoland/deno/issues/3082))
- Rollup cache support for incremental compiles in [denofn/denopack/pull/5](https://github.com/denofn/denopack/pull/5)
- File watch mode (pluginTypescriptCompile is **not** supported) in [denofn/denopack/pull/5](https://github.com/denofn/denopack/pull/5)
- Handle entry file redirects (re:
[denoland/deno/issues/3082](https://github.com/denoland/deno/issues/3082))
- Rollup cache support for incremental compiles in
[denofn/denopack/pull/5](https://github.com/denofn/denopack/pull/5)
- File watch mode (pluginTypescriptCompile is **not** supported) in
[denofn/denopack/pull/5](https://github.com/denofn/denopack/pull/5)

### Changed

- Default plugin hook changed from useCompile to useCache in [denofn/denopack/pull/5](https://github.com/denofn/denopack/pull/5)
- Extra CLI options like print, watch and cache are now verbose in [denofn/denopack/pull/5](https://github.com/denofn/denopack/pull/5)
- Default plugin hook changed from useCompile to useCache in
[denofn/denopack/pull/5](https://github.com/denofn/denopack/pull/5)
- Extra CLI options like print, watch and cache are now verbose in
[denofn/denopack/pull/5](https://github.com/denofn/denopack/pull/5)
- File watch uses debounce, taking last event in series as a trigger

## [0.3.2](https://github.com/denofn/denopack/compare/0.3.0..0.3.2) - 2020-08-08

### Fixed

- Load config from file URI relative to CWD instead of absolute path (this broke stuff on installs from registries)
- Load config from file URI relative to CWD instead of absolute path (this broke
stuff on installs from registries)

## [0.3.0](https://github.com/denofn/denopack/compare/0.2.0..0.3.0) - 2020-08-07

### Added

- Source map support in [denofn/denopack/pull/2](https://github.com/denofn/denopack/pull/2)
- Lockfile integrity checking in [denofn/denopack/pull/4](https://github.com/denofn/denopack/pull/4)
- Source map support in
[denofn/denopack/pull/2](https://github.com/denofn/denopack/pull/2)
- Lockfile integrity checking in
[denofn/denopack/pull/4](https://github.com/denofn/denopack/pull/4)

### Changed

- Hooks now take one configuration object as parameter where needed in [denofn/denopack/pull/4](https://github.com/denofn/denopack/pull/4)
- Hooks now take one configuration object as parameter where needed in
[denofn/denopack/pull/4](https://github.com/denofn/denopack/pull/4)
52 changes: 27 additions & 25 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,43 @@
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
size, disability, ethnicity, sex characteristics, gender identity and
expression, level of experience, education, socio-economic status, nationality,
personal appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
Project maintainers have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, or to ban temporarily or permanently any
contributor for other behaviors that they deem inappropriate, threatening,
offensive, or harmful.

## Scope

Expand All @@ -58,17 +58,19 @@ Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [email protected]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
obligated to maintain confidentiality with regard to the reporter of an
incident. Further details of specific enforcement policies may be posted
separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 1.4, available at
https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

Expand Down
33 changes: 19 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
# Contributing

- If you are using vscode, install and enable the [required extensions](./.vscode/extensions.json).
- If you are not using vscode, sort your imports and use the following prettier settings:
- semi: true
- singleQuote: false
- printWidth: 100
- trailingComma: "es5"
- tabWidth: 2
- useTabs: false
- If you are using vscode, install and enable the
[required extensions](./.vscode/extensions.json).
- If you are not using vscode, sort your imports and run `deno fmt`.
- Functions, constants and variables are always camelCase
- Classes are allowed to be PascalCase
- Extract shared code to [util](./util)
- Code that is not a plugin or hook lives in [cli](./cli)

## Contributing denopack plugins

Contributing a plugin to the denopack repo is not only extremely welcomed, it's even encouraged. That does mean a few conventions are in order, extending from the existing [Rollup conventions](https://rollupjs.org/guide/en/#conventions) these are:
Contributing a plugin to the denopack repo is not only extremely welcomed, it's
even encouraged. That does mean a few conventions are in order, extending from
the existing [Rollup conventions](https://rollupjs.org/guide/en/#conventions)
these are:

- Plugins should have a clear plugin name with a `denopack-plugin-` prefix
- Plugin functions are always camelCased and are default exported
- Plugins and their documentation should be stored in a separate folder [inside the plugin directory](./plugin)
- Optionally also indicating what the most impactful action is (resolve, load, transform, bundle ...). The [typescriptCompile](./plugin/typescriptCompile) plugin is an obvious exception, but do take a look at the naming of the [other plugins](./plugin)
- Plugins and their documentation should be stored in a separate folder
[inside the plugin directory](./plugin)
- Optionally also indicating what the most impactful action is (resolve, load,
transform, bundle ...). The [typescriptCompile](./plugin/typescriptCompile)
plugin is an obvious exception, but do take a look at the naming of the
[other plugins](./plugin)
- Use async Deno APIs (readFile not readFileSync, etc.)
- Document your plugin in English and **detail what flags are required**! [Here's an example](./plugin/typescriptCompile/README.md)
- Document your plugin in English and **detail what flags are required**!
[Here's an example](./plugin/typescriptCompile/README.md)

## Contributing denopack hooks

Expand All @@ -32,5 +35,7 @@ Contributing a hook follows the following conventions:
- Hooks are always camelCased
- Hooks are stored inside of [hooks.ts](./plugin/hooks.ts)
- Hooks are always functions and always return an array of plugins
- Using plugins that accept configuration options in hooks should always be allowed to pass config down to that plugin
- Configuration options are stored in one object containing all configuration options, see [hooks.ts](./plugin/hooks.ts) for examples
- Using plugins that accept configuration options in hooks should always be
allowed to pass config down to that plugin
- Configuration options are stored in one object containing all configuration
options, see [hooks.ts](./plugin/hooks.ts) for examples
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

## Preface

🦕📦 denopack is a CLI tool and a collection of plugins designed for bundling code to be used with Deno or in the browser. _No node_modules, no npm or yarn needed._
🦕📦 denopack is a CLI tool and a collection of plugins designed for bundling code
to be used with Deno or in the browser. _No node_modules, no npm or yarn
needed._

**General note: make sure you are running Deno v1.2.0 or later**
jeiea marked this conversation as resolved.
Show resolved Hide resolved

Expand All @@ -26,7 +28,8 @@ deno run --allow-run --allow-read https://deno.land/x/[email protected]/install.ts
deno run --allow-run --allow-read https://x.nest.land/[email protected]/install.ts
```

**NOTE: denopack uses unstable Deno APIs. These APIs are not final and may break, but this does mean `--unstable` is mandatory!**
**NOTE: denopack uses unstable Deno APIs. These APIs are not final and may
break, but this does mean `--unstable` is mandatory!**

## Documentation

Expand All @@ -38,5 +41,8 @@ See [CONTRIBUTING.md](./CONTRIBUTING.md)

## Acknowledgements

- Reddit user [u/HarmonicAscendant](https://www.reddit.com/r/Deno/comments/hlm7dd/any_frontend_build_tools_for_deno_yet/) - unrelated to this library - who coined the name name Denopack
- The sauropod and package emoji's courtesy of [Twemoji](https://twemoji.twitter.com/)
- Reddit user
[u/HarmonicAscendant](https://www.reddit.com/r/Deno/comments/hlm7dd/any_frontend_build_tools_for_deno_yet/) -
unrelated to this library - who coined the name name Denopack
- The sauropod and package emoji's courtesy of
[Twemoji](https://twemoji.twitter.com/)
2 changes: 1 addition & 1 deletion cli/persistCache.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { RollupCache } from "../deps.ts";

export async function persistCache(
export function persistCache(
cachePath: string,
cache: RollupCache,
): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion docs/customWatchScript.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { debounce } from "../deps.ts";

async function watch() {
const run = debounce(async function () {
const run = debounce(() => {
Deno.run({
cmd: ["vr", "start"],
});
Expand Down
18 changes: 13 additions & 5 deletions plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,18 @@ denopack provides several built-in plugins that you can use

## Hooks

Some of these plugins are collected in strategies that are defined as hooks. These hooks will always return as an array of plugins. Your choice in strategy will probably depend on the permissions you want the bundling to happen with:
Some of these plugins are collected in strategies that are defined as hooks.
These hooks will always return as an array of plugins. Your choice in strategy
will probably depend on the permissions you want the bundling to happen with:

- `useCacheLazy` is the least invasive, always resolving to a file (thus needing `--allow-read`). The downside is that everything already needs to be pre-cached before bundling starts. It does also require access to environment variables to find DENO_DIR (`--allow-env`)
- `useCache` require an additional, potential `--allow-net` if files aren't cached yet.
- `useAlwaysFetch`, `useCompile` and `useCompileAsLoader` require `--allow-read` and `--allow-net`
- `useCacheLazy` is the least invasive, always resolving to a file (thus needing
`--allow-read`). The downside is that everything already needs to be
pre-cached before bundling starts. It does also require access to environment
variables to find DENO_DIR (`--allow-env`)
- `useCache` require an additional, potential `--allow-net` if files aren't
cached yet.
- `useAlwaysFetch`, `useCompile` and `useCompileAsLoader` require `--allow-read`
and `--allow-net`

**NOTE: aside from permission flags, all of these hooks require `--unstable` to leverage compilation/transpilation**
**NOTE: aside from permission flags, all of these hooks require `--unstable` to
leverage compilation/transpilation**
11 changes: 8 additions & 3 deletions plugin/cacheLoader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@

## Options

- `lazy [boolean]`: defaults to false. If active, this will skip checking whether the file actually exists locally and will lazily return the assumed path
- `cacheOnly [boolean]`: throws if an external dependency is not found inside the cache
- `lockFile [string]`: path to a lockfile (for example: `lock.json`). Throws if the integrity of the loaded cache file does not match the integrity in the lockfile
- `lazy [boolean]`: defaults to false. If active, this will skip checking
whether the file actually exists locally and will lazily return the assumed
path
- `cacheOnly [boolean]`: throws if an external dependency is not found inside
the cache
- `lockFile [string]`: path to a lockfile (for example: `lock.json`). Throws if
the integrity of the loaded cache file does not match the integrity in the
lockfile

## Required flags

Expand Down
2 changes: 1 addition & 1 deletion plugin/cacheLoader/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function pluginCacheLoader(opts: Opts = {}): Plugin {

return {
name: "denopack-plugin-cacheLoader",
async load(id) {
load(id) {
if (!isHttpUrl(id)) return null;
return cacheLoader(id, opts, lockFile);
},
Expand Down
Loading