Commit graph

50 commits

Author SHA1 Message Date
Matt Mastracci a561cc28cd
chore(cli) Use with_context(|| format!(...)) rather than context(format!(...)) to avoid allocations in non-error path (#18332) 2023-03-21 12:13:32 -06:00
Bartek Iwańczuk 6f308b3af0
test: fix flaky resolve_import_map_flags_take_precedence test (#18182)
Trying to fix https://github.com/denoland/deno/issues/18180
2023-03-14 13:37:15 +02:00
Bartek Iwańczuk 48ede89f1f
refactor(core): resolve_url_or_path and resolve_url_or_path_deprecated (#18170)
This commit changes current "deno_core::resolve_url_or_path" API to
"resolve_url_or_path_deprecated" and adds new "resolve_url_or_path"
API that requires to explicitly pass the directory from which paths
should be resolved to. 

Some of the call sites were updated to use the new API, the reminder
of them will be updated in a follow up PR.

Towards landing https://github.com/denoland/deno/pull/15454
2023-03-14 01:12:09 +00:00
David Sherret bcb6ee9d08
refactor(npm): push npm struct creation to a higher level (#18139)
This has been bothering me for a while and it became more painful while
working on #18136 because injecting the shared progress bar became very
verbose. Basically we should move the creation of all these npm structs
up to a higher level.

This is a stepping stone for a future refactor where we can improve how
we create all our structs.
2023-03-12 23:32:59 -04:00
Bartek Iwańczuk bb07e230d1
chore: update Rust to 1.68.0 (#18102) 2023-03-09 19:18:00 +00:00
David Sherret 84bafd11d5
fix: lazily surface errors in package.json deps parsing (#17974)
Closes #17941
2023-03-03 18:27:05 -04:00
David Sherret a27d0885f4
feat: add DENO_NO_PACKAGE_JSON env var (#17926)
Depends on #17924

Part of #17916
2023-02-24 19:23:07 +00:00
David Sherret 7ad64283a1
fix(npm): package.json auto-discovery should respect --no-config and --no-npm (#17924)
Part of #17916
2023-02-24 13:51:21 -05:00
David Sherret 6233c0aff0
fix(npm): support bare specifiers in package.json having a path (#17903)
For example `import * as test from "package/path.js"`
2023-02-23 17:33:23 +00:00
David Sherret 344317ec50
feat(npm): support bare specifiers from package.json in more subcommands and language server (#17891) 2023-02-23 10:58:10 -05:00
David Sherret b15f9e60a0
feat(task): support scripts in package.json (#17887)
This is a super basic initial implementation. We don't create a
`node_modules/.bin` folder at the moment and add it to the PATH like we
should which is necessary to make command name resolution in the
subprocess work properly (ex. you run a script that launches another
script that then tries to launch an "npx command"... this won't work
atm).

Closes #17492
2023-02-22 22:45:35 -05:00
David Sherret ddc350780d
fix(npm): resolve node_modules dir relative to package.json instead of cwd (#17885) 2023-02-22 20:16:16 -05:00
Bartek Iwańczuk 4d1a14ca7f
feat: auto-discover package.json for npm dependencies (#17272)
This commits adds auto-discovery of "package.json" file when running
"deno run" and "deno task" subcommands. In case of "deno run" the
"package.json" is being looked up starting from the directory of the
script that is being run, stopping early if "deno.json(c)" file is found
(ie. FS tree won't be traversed "up" from "deno.json").

When "package.json" is discovered the "--node-modules-dir" flag is
implied, leading to creation of local "node_modules/" directory - we
did that, because most tools relying on "package.json" will expect
"node_modules/" directory to be present (eg. Vite). Additionally 
"dependencies" and "devDependencies" specified in the "package.json"
are downloaded on startup. 

This is a stepping stone to supporting bare specifier imports, but
the actual integration will be done in a follow up commit.

---------

Co-authored-by: David Sherret <dsherret@gmail.com>
2023-02-20 19:14:06 +01:00
Serhiy Barhamon fc843d035c
feat(bench): Add JSON reporter for "deno bench" subcommand (#17595) 2023-02-12 17:40:45 +00:00
David Sherret b3e88e0681
refactor: deno_graph 0.43 upgrade (#17692) 2023-02-09 22:00:23 -05:00
David Sherret f5840bdcd3
chore: upgrade to Rust 1.67 (#17548)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-01-27 10:43:16 -05:00
David Sherret 34c14dbf99
fix: support import map specified as data uri (#17531) 2023-01-25 16:51:04 -05:00
Bartek Iwańczuk c6c8c91a6e
feat: embed import map in the config file (#17478)
This commit changes handling of config file to enable
specifying "imports" and "scopes" objects effectively making
the configuration file an import map.

"imports" and "scopes" take precedence over "importMap" configuration,
but have lower priority than "--importmap" CLI flag.

Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
Co-authored-by: David Sherret <dsherret@gmail.com>
2023-01-25 21:13:40 +01:00
David Sherret b5b4887c4a
feat(fmt): make semi-colon option a boolean (#17527) 2023-01-25 15:06:00 -05:00
Bartek Iwańczuk e1c51f3c0d
feat(fmt): add ability to configure semicolons (#17292)
Allows to change behavior of `deno fmt` to use "ASI" setting for
semicolons instead of always prefering them, this is done
by "--options-semi=asi" flag or `"semi": "asi"` setting
in the config file.
2023-01-24 21:07:00 +01:00
Bartek Iwańczuk bf237c6241
refactor: Move lockfile to a separate crate (#17503)
Moves the lockfile implementation to a separate crate so other projects
like Deploy can use it as well.
2023-01-23 23:41:02 +01:00
Andreu Botella 69ec45eac7
refactor(cli): Integrate standalone mode cert handling into Flags (#17419)
The way the standalone mode handles the `--cert` flag is different to
all other modes. This is because `--cert` takes a path to the
certificate file, which is directly added to the root cert store; except
for compile mode, where its byte contents are stored in the standalone
metadata, and they are added to the root cert store after the
`ProcState` is created.

This change instead changes `Flags::ca_file` (an `Option<String>`) into
`Flags::ca_data`, which can represent a `String` file path or a
`Vec<u8>` with the certificate contents. That way, standalone mode can
create a `ProcState` whose root cert store alreay contains the
certificate.

This change also adds a tests for certificates in standalone mode, since
there weren't any before.

This refactor will help with implementing web workers in standalone mode
in the future.
2023-01-18 01:18:24 +01:00
Geert-Jan Zwiers 84ef26ac9b
refactor(cli/tools): move flag and config logic to CliOptions (#17008)
Co-authored-by: David Sherret <dsherret@gmail.com>
2023-01-07 15:22:09 -05:00
Yiyu Lin 896dd56b7a
refactor(cli,core,ext,rt): remove some unnecessary clone or malloc (#17274) 2023-01-05 14:29:50 -05:00
David Sherret 10e4b2e140
chore: update copyright year to 2023 (#17247)
Yearly tradition of creating extra noise in git.
2023-01-02 21:00:42 +00:00
linbingquan f46df3e359
chore: update to Rust 1.66.0 (#17078) 2022-12-17 23:20:15 +01:00
Bartek Iwańczuk efcb93f8b9
fix(npm): fix require resolution if using --node-modules-dir (#17087)
In our `require()` implementation we use a special logic to resolve
"base path" when looking for matching packages, however this logic
is in contradiction to what needs to happen if there's a local
"node_modules"
directory used. This commit changes require implementation to be aware
if we're running off of global node modules cache or a local one.
2022-12-16 23:41:51 +01:00
Bartek Iwańczuk 4a17c93088
feat: add --inspect-wait flag (#17001)
This commit adds new "--inspect-wait" flag which works similarly
to "--inspect-brk" in that it waits for inspector session to be
established before running code. However it doesn't break on the first
statement of user code, but instead runs it as soon as a session
is established.
2022-12-12 15:33:30 +01:00
Geert-Jan Zwiers 890b065310
feat(cli): support deno bench in the config file (#16608)
This PR adds the ability to set `include/exclude` fields for `deno
bench` in the configuration file.
2022-12-10 02:30:47 +01:00
David Sherret 91443bbc0b
fix(compile): ensure import map is used when specified in deno config file (#16990)
Closes #14246
2022-12-08 11:50:09 -05:00
Bartek Iwańczuk d1962e07af
fix(repl): respect --quiet flag (#16875)
This commit changes REPL behavior to respect --quiet flag. Once 
this flag is present REPL will not print a banner at the start.
2022-11-30 23:25:20 +01:00
David Sherret 2d4c46c975
refactor: create util folder, move nap_sym to napi/sym, move http_cache to cache folder (#16857) 2022-11-28 17:28:54 -05:00
David Sherret 0c0af67f89
refactor: DenoDir - move to cache folder and make root_dir private (#16823) 2022-11-26 00:04:30 +00:00
David Sherret dcb4ffb93a
refactor: move dts files, diagnostics.rs, and tsc.rs to tsc folder (#16820) 2022-11-25 18:29:48 -05:00
David Sherret 0cc90d9246
refactor: move lockfile.rs to args module (#16818)
This should be in the `args` folder as it's similar to `config_file`.
2022-11-25 17:00:28 -05:00
Bartek Iwańczuk 5dea510b02
fix(lock): autodiscovery of lockfile (#16498)
This commit adds autodiscovery of lockfile. 

This only happens if Deno discovers the configuration file (either 
"deno.json" or "deno.jsonc"). In such case Deno tries to load
"deno.lock"
file that sits next to the configuration file, or creates one for user
if
the lockfile doesn't exist yet.

As a consequence, "--lock" and "--lock-write" flags had been updated.
"--lock" no longer requires a value, if one is not provided, it defaults
to "./deno.lock" resolved from the current working directory.
"--lock-write"
description was updated to say that it forces to overwrite a lockfile.

Autodiscovery is currently not handled by the LSP.
2022-11-02 16:32:30 +01:00
Mark Gibson fda24b54e9
fix(cli): allow importMap to be an absolute URL within the deno config file (#16234) 2022-10-13 11:01:11 +02:00
David Sherret 716005a0d4
feat(npm): add flag for creating and resolving npm packages to a local node_modules folder (#15971) 2022-09-22 11:17:02 -04:00
Bartek Iwańczuk 4a250b2f25
feat: add --no-npm flag to disable npm: imports (#15673)
This commit adds "--no-npm" flag, it's similar to "--no-remote"
flag. This flag makes Deno error out if "npm:" specifier is encountered.
2022-09-07 15:33:51 +02:00
Bartek Iwańczuk e324151520
BREAKING(unstable): remove --compat mode (#15678)
This commit removes "compat" mode. We shipped support for "npm:" specifier
support in v1.25 and that is preferred way to interact with Node code that we
will iterate and improve upon.
2022-09-03 18:19:30 +02:00
Luca Casonato 33c4d45328
fix: resolve jsxImportSource relative to module (#15561)
Previously `jsxImportSource` was resolved relative to the config file
during graph building, and relative to the emitted module during
runtime.

This is now fixed so that the JSX import source is resolved relative to
the module both during graph building and at runtime.
2022-08-24 19:36:05 +02:00
David Sherret 8eed24cd3d
fix(coverage): ensure coverage is only collected in certain situations (#15467) 2022-08-12 15:21:17 -04:00
David Sherret c3b04683c5
refactor(cli): consolidate most MainWorker related code to the same place (#15459) 2022-08-11 16:59:12 -04:00
David Sherret 0ab262b901
feat: emit files on demand and fix racy emit (#15220) 2022-07-19 11:58:18 -04:00
Roj 70d1ecaeaa
feat(cli): support configuring the test tool in the config file (#15079) 2022-07-18 15:12:19 -04:00
David Sherret 95d2f206fc
refactor: extract deno_graph::create_graph use to common function (#15009) 2022-07-01 11:50:16 -04:00
David Sherret e46584a75a
fix(vendor): ignore import map in output directory instead of erroring (#14998) 2022-06-29 20:41:48 -04:00
David Sherret 8c4420c005
refactor: rename RootConfig to CliOptions (#15007) 2022-06-29 11:51:11 -04:00
David Sherret 01adbb1efb
refactor: add RootConfig (#14985) 2022-06-28 16:45:55 -04:00
David Sherret e1c90963fb
refactor: create args folder (#14982) 2022-06-27 16:54:09 -04:00