summaryrefslogtreecommitdiff
path: root/tests/specs/npm
AgeCommit message (Collapse)Author
2024-11-19fix(node): handle resolving ".//<something>" in npm packages (#26920)David Sherret
The issue was this package had an import like: `".//index.js"` and we resolved that as specified, but node normalizes it to `"./index.js"` so we have to copy node.
2024-11-16chore: reenable some tests disabled during Deno 1->2 migration (#26898)Bartek Iwańczuk
2024-11-15fix: update message for unsupported schemes with npm and jsr (#26884)Bartek Iwańczuk
Closes https://github.com/denoland/deno/issues/26596
2024-11-13feat(node): stabilize detecting if CJS via `"type": "commonjs"` in a ↵David Sherret
package.json (#26439) This will respect `"type": "commonjs"` in a package.json to determine if `.js`/`.jsx`/`.ts`/.tsx` files are CJS or ESM. If the file is found to be ESM it will be loaded as ESM though.
2024-11-12fix(install): re-setup bin entries after running lifecycle scripts (#26752)Nathan Whitaker
Fixes #26677 Some packages (like supabase) declare bin entries that don't exist until lifecycle scripts are run. For instance, the lifecycle script downloads a binary file which serves as a bin entrypoint. Unfortunately you can't just defer setting up the bin entries until after lifecycle scripts have run, because the scripts may rely on them. I looked into this, and PNPM just re-links bin entries after running lifecycle scripts. I think that's about the best we can do as well. Note that we'll only re-setup bin entries for packages whose lifecycle scripts we run. This should limit the performance cost, as typically a given project will not have many lifecycle scripts (and of those, many of them probably don't have bin entries to set up).
2024-11-01fix: improved support for cjs and cts modules (#26558)David Sherret
* cts support * better cjs/cts type checking * deno compile cjs/cts support * More efficient detect cjs (going towards stabilization) * Determination of whether .js, .ts, .jsx, or .tsx is cjs or esm is only done after loading * Support `import x = require(...);` Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-10-31fix(cli): set `npm_config_user_agent` when running npm packages or tasks ↵Nathan Whitaker
(#26639) Fixes #25342. Still not sure on the exact user agent to set (should it include `node`?). After this PR, here's the state of running some `create-*` packages (just ones I could think of off the top of my head): | package | prints/runs/suggests deno install | notes | | ---------------- | ------------- | ------ | | `create-next-app` | ❌ | falls back to npm, needs a PR ([code](https://github.com/vercel/next.js/blob/c32e2802097c03fd9f95b1dae228d6e0257569c0/packages/create-next-app/helpers/get-pkg-manager.ts#L3)) | `sv create` | ❌ | uses `package-manager-detector`, needs a PR ([code](https://github.com/antfu-collective/package-manager-detector/tree/main)) | `create-qwik` | ✅ | runs `deno install` but suggests `deno start` which doesn't work (should be `deno task start` or `deno run start`) | `create-astro` | ✅ | runs `deno install` but suggests `npm run dev` later in output, probably needs a PR | `nuxi init` | ❌ | deno not an option in dialog, needs a PR ([code](https://github.com/nuxt/cli/blob/f04e2e894446f597da9d971b7eb03191d5a0da7e/src/commands/init.ts#L96-L102)) | `create-react-app` | ❌ | uses npm | `ng new` (`@angular/cli`) | ❌ | uses npm | `create-vite` | ✅ | suggests working deno commands 🎉 | `create-solid` | ❌ | suggests npm commands, needs PR It's possible that fixing `package-manager-detector` or other packages might make some of these just work, but haven't looked too carefully at each
2024-10-28fix(check): expose more globals from @types/node (#26603)David Sherret
Extracted out of https://github.com/denoland/deno/pull/26558 Closes https://github.com/denoland/deno/issues/26578
2024-10-28fix(npm): match npm bearer token generation (#26544)Marvin Hagemeister
Spend some time stepping through the npm client code and noticed that the bearer token was different from ours. They do some double encoding and @dsherret helped me in matching the encoding behavior. Fixes https://github.com/denoland/deno/issues/26033
2024-10-24fix: `.npmrc` settings not being passed to install/add command (#26473)Marvin Hagemeister
We weren't passing the resolved npmrc settings to the install commands. This lead us to always fall back to the default registry url instead of using the one from npmrc. Fixes https://github.com/denoland/deno/issues/26139 Fixes https://github.com/denoland/deno/issues/26033 Fixes https://github.com/denoland/deno/issues/25924 Fixes https://github.com/denoland/deno/issues/25822 Fixes https://github.com/denoland/deno/issues/26152 --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-10-18fix(npm): ensure scoped package name is encoded in URLs (#26390)Marvin Hagemeister
Fixes https://github.com/denoland/deno/issues/26385
2024-10-14feat(cli): improve deno info output for npm packages (#25906)Luca Casonato
2024-10-12feat(npm): support `--allow-scripts` on `deno run` (and `deno add`, `deno ↵Nathan Whitaker
test`, etc) (#26075) Fixes https://github.com/denoland/deno/issues/25533. Fixes https://github.com/denoland/deno/issues/25396. Previously we only supported it on `deno install` and `deno cache`, which is annoying if you're using `nodeModulesDir: auto`. Also changes from printing output of lifecycle scripts directly to capturing the output and only printing it on error.
2024-10-02feat(byonm): support `deno run npm:<package>` when package is not in ↵David Sherret
package.json (#25981) Closes https://github.com/denoland/deno/issues/25905
2024-10-02chore: remove unnecessary envs in spec tests (#25982)David Sherret
2024-09-30fix: precompile preserve SVG camelCase attributes (#25945)Marvin Hagemeister
See https://github.com/denoland/deno_ast/pull/278 Fixes https://github.com/denoland/deno/issues/25810
2024-09-26fix(info): move "version" field to top of json output (#25890)David Sherret
2024-09-26feat(install): warn repeatedly about not-run lifecycle scripts on explicit ↵Nathan Whitaker
installs (#25878) Currently we only warn once. With this PR, we continue to warn about not-run scripts on explicit `deno install` (or cache). For `run` (or other subcommands) we only warn the once, as we do currently.
2024-09-26fix(installl): make bin entries executable even if not put in ↵Nathan Whitaker
`node_modules/.bin` (#25873) Fixes https://github.com/denoland/deno/issues/25862. npm only makes bin entries executable if they get linked into `.bin`, as we did before this PR. So this PR actually deviates from npm, because it's the only reasonable way to fix this that I can think of. --- The reason this was broken in moment is the following: Moment has dependencies on two typescript versions: 1.8 and 3.1 If you have two packages with conflicting bin entries (i.e. two typescript versions which both have a bin entry `tsc`), in npm it is non-deterministic and undefined which one will end up in `.bin`. npm, due to implementation differences, chooses to put typescript 1.8 into the `.bin` directory, and so `node_modules/typescript/bin/tsc` ends up getting marked executable. We, however, choose typescript 3.2, and so we end up making `node_modules/typescript3/bin/tsc` executable. As part of its tests, moment executes `node_modules/typescript/bin/tsc`. Because we didn't make it executable, this fails. Since the conflict resolution is undefined in npm, instead of trying to match it, I think it makes more sense to just make bin entries executable even if they aren't chosen in the case of a conflict.
2024-09-26feat: add `--allow-import` flag (#25469)Bartek Iwańczuk
This replaces `--allow-net` for import permissions and makes the security sandbox stricter by also checking permissions for statically analyzable imports. By default, this has a value of `--allow-import=deno.land:443,jsr.io:443,esm.sh:443,raw.githubusercontent.com:443,gist.githubusercontent.com:443`, but that can be overridden by providing a different set of hosts. Additionally, when no value is provided, import permissions are inferred from the CLI arguments so the following works because `fresh.deno.dev:443` will be added to the list of allowed imports: ```ts deno run -A -r https://fresh.deno.dev ``` --------- Co-authored-by: David Sherret <dsherret@gmail.com>
2024-09-24fix(cli): Warn on not-run lifecycle scripts with global cache (#25786)Nathan Whitaker
Refactors the lifecycle scripts code to extract out the common functionality and then uses that to provide a warning in the global resolver. While ideally we would still support them with the global cache, for now a warning is at least better than the status quo (where people are unaware why their packages aren't working).
2024-09-20refactor(tests): migrate npm itests to specs (#25764)Satya Rohith
Towards https://github.com/denoland/deno/issues/25241
2024-09-19fix: cjs resolution cases (#25739)snek
Fixes cjs modules being loaded as esm.
2024-09-18feat: improve warnings for deprecations and lifecycle script for npm ↵Bartek Iwańczuk
packages (#25694) This commit improves warning messages for deprecated npm packages and packages that rely on lifecycle script.
2024-09-16fix(npm): better error handling for remote npm deps (#25670)David Sherret
* https://github.com/denoland/deno_npm/pull/68
2024-09-04fix: lock down allow-run permissions more (#25370)David Sherret
`--allow-run` even with an allow list has essentially been `--allow-all`... this locks it down more. 1. Resolves allow list for `--allow-run=` on startup to an absolute path, then uses these paths when evaluating if a command can execute. Also, adds these paths to `--deny-write` 1. Resolves the environment (cwd and env vars) before evaluating permissions and before executing a command. Then uses this environment to evaluate the permissions and then evaluate the command.
2024-09-03fix(flags): require global flag for permission flags in install subcommand ↵Leo Kettmeir
(#25391) Also rewrites some of the subcommands help text Closes https://github.com/denoland/deno/issues/25362 --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-09-03fix: make some warnings more standard (#25324)David Sherret
2024-09-02BREAKING: remove `deno bundle` (#25339)Asher Gomez
`deno bundle` now produces: ``` error: ⚠️ `deno bundle` was removed in Deno 2. See the Deno 1.x to 2.x Migration Guide for migration instructions: https://docs.deno.com/runtime/manual/advanced/migrate_deprecations ``` `deno bundle --help` now produces: ``` ⚠️ `deno bundle` was removed in Deno 2. See the Deno 1.x to 2.x Migration Guide for migration instructions: https://docs.deno.com/runtime/manual/advanced/migrate_deprecations Usage: deno bundle [OPTIONS] Options: -q, --quiet Suppress diagnostic output --unstable Enable all unstable features and APIs. Instead of using this flag, consider enabling individual unstable features To view the list of individual unstable feature flags, run this command again with --help=unstable ```
2024-08-31chore: remove DENO_FUTURE=1 from spec tests (#25329)Bartek Iwańczuk
Towards https://github.com/denoland/deno/issues/25241
2024-08-30refactor: remove DENO_FUTURE (#25314)David Sherret
2024-08-30BREAKING: `DENO_FUTURE=1` by default, or welcome to Deno 2.0 (#25213)Bartek Iwańczuk
This commit effectively turns Deno into Deno 2.0. This is done by forcing `DENO_FUTURE=1` env var, that was available in the past few months to try Deno 2 changes. This commit contains several breaking changes scheduled for Deno 2: - all deprecated JavaScript APIs are not available any more, mostly `Deno.*` APIs - `window` global is removed - FFI, WebGPU and FS APIs are now stable and don't require `--unstable-*` flags - import assertions are no longer supported - "bring your own node modules" is enabled by default This is the first commit in a series that are scheduled before the Deno 2 release. Follow up work is tracked in https://github.com/denoland/deno/issues/25241. --------- Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com> Co-authored-by: Nayeem Rahman <nayeemrmn99@gmail.com> Co-authored-by: Nathan Whitaker <nathan@deno.com>
2024-08-29feat(config): Node modules option for 2.0 (#25299)Nathan Whitaker
2024-08-29test: run specs::npm::exec_file_inside_npm_package with DENO_FUTURE=1 (#25282)Bartek Iwańczuk
The test is failing if run with `DENO_FUTURE=1` which is blocking https://github.com/denoland/deno/pull/25213. --------- Co-authored-by: David Sherret <dsherret@gmail.com>
2024-08-28feat: improve lockfile v4 to store normalized version constraints and be ↵David Sherret
more terse (#25247) Stores normalized version constraints in the lockfile, which will improve reproducibility and will fix a bug with duplicate specifiers ending up in the lockfile. Also, gets rid of some duplicate data in the specifiers area of the lockfile.
2024-08-28fix: replace `npm install` hint with `deno install` hint (#25244)Bartek Iwańczuk
Needed for https://github.com/denoland/deno/pull/25213. With Deno 2, we should suggest using `deno install` instead of `npm install`.
2024-08-26feat: lockfile v4 by default (#25165)David Sherret
This won't be fully stabilized until 2.0 is released.
2024-08-22chore: enable `log` feature for tracing crate (#25078)Yusuke Tanaka
This commit enables the `log` feature for the `tracing` crate. This allows us to examine additional detailed logs emitted by third party crates that use `tracing` crate for logging by setting `RUST_LOG` env var or passing `-L` option in command line. Closes #25045
2024-08-20fix: adjust suggestion for lockfile regeneration (#25107)Bartek Iwańczuk
Ref https://github.com/denoland/deno/pull/24436#issuecomment-2288568645
2024-08-17fix(ext/node): fix prismjs compatibiliy in Web Worker (#25062)Yoshiya Hinosawa
PrismJS uses `WorkerGlobalScope` and `self` for detecting browser's Web Worker context: https://github.com/PrismJS/prism/blob/59e5a3471377057de1f401ba38337aca27b80e03/prism.js#L11 Now the detection logic above is broken when it's imported from Deno's Web Worker context because we only hide `self` (Prism assumes when `WorkerGlobalScope` is available, `self` is also available). This change fixes the above by also hiding `WorkerGlobalScope` global in Node compat mode. closes #25008
2024-08-16fix(ext/node): improve shelljs compat with managed npm execution (#24912)Yoshiya Hinosawa
This change improves the Node.js compatibility in managed npm resolution mode by disabling the discovery of `node_modules` when the main specifier is inside of `DENO_DIR`. closes #22732 closes #24589
2024-08-14feat(node): support `username` and `_password` in `.npmrc` file (#24793)Asher Gomez
Closes #23950
2024-07-24fix(future): Emit `deno install` warning less often, suggest `deno install` ↵Nathan Whitaker
in error message (#24706) Two small changes: - In our BYONM errors, suggest running `deno install` instead of `npm install` if `DENO_FUTURE` is set - Only emit warning about `deno install` changes if you do `deno install <foo>` with deno_future unset
2024-07-24fix(node): better detection for when to surface node resolution errors (#24653)David Sherret
2024-07-19fix(cli): Respect implied BYONM from DENO_FUTURE in `deno task` (#24652)Nathan Whitaker
Regression from https://github.com/denoland/deno/commit/04f9db5b2217fe06f88e76146aac6362ff0b0b86 Originally I thought to fix the issue in the PR we needed to explicitly pass through the `node-modules-dir` flag, but after applying the correct fix that david pointed out (setting `NPM_PROCESS_STATE`) that wasn't necessary (or correct). We had a test for deno task with BYONM, but it only tested with `"unstable": ["byonm"]` in deno.json, so it didn't catch this.
2024-07-18chore: fix ci (#24633)David Sherret
2024-07-17fix(publish): surface syntax errors when using --no-check (#24620)David Sherret
2024-07-18chore: fix flakey lifecycle scripts test (#24629)Nathan Whitaker
Failed in https://github.com/denoland/deno/actions/runs/9982978127/job/27589707376
2024-07-17fix(workspace): support resolving bare specifiers to npm pkgs within a ↵David Sherret
workspace (#24611) This makes bare specifiers for npm packages work when inside a workspace, which emulates the same behaviour as when there's a node_modules directory. The bare specifier can be overwritten by specifying an import map entry or package.json dependency entry. * https://github.com/denoland/deno_config/pull/88 Closes #24605
2024-07-16fix(cli): Create child node_modules for conflicting dependency versions, ↵Nathan Whitaker
respect aliases in package.json (#24609) Fixes #24419.