Possibly related to #12526?
Pinned
Activity
gristow issue comment vitejs/vite
tsconfig files ignored when importing ts files from sibling directories
Describe the bug
When importing a typescript file from a sibling directory to the vite directory, whether by relative imports or via an alias, neither the tsconfig.json settings of the vite directory nor of the sibling directory are applied.
To reproduce:
- clone the repo:
git clone https://github.com/gristow/vite-sibling-tsconfig.git
- run
yarn
ornpm i
in thevite
subdirectory - run
yarn
ornpm i
in thesibling
directory. - run
yarn dev
ornpm run dev
in thevite
subdirectory.
In this demonstration, identical files (./vite/src/lib/mobxNonSiblingDemo and ./sibling/src/mobxSiblingDemo) are imported into App.svelte.
The tsconfig compilerOptions.useDefineForClassFields
is respected and compiled correctly for the file in the vite/src/lib
directory, but not for the one in the sibling/src
directory. As a result, it becomes impossible to observe certain properties on mobx stores.
Relevant Files:
vite-sibling-tsconfig (root)
└───vite
│ └──src
│ │- App.svelte
│ │
│ └──lib
│ │- mobxNonSiblingDemo.ts
│
└───sibling
└──src
│ │- mobxSiblingDemo.ts
│
│- tsconfig.json
Reproduction
https://github.com/gristow/vite-sibling-tsconfig
System Info
System:
OS: macOS 12.2.1
CPU: (10) arm64 Apple M1 Max
Memory: 11.68 GB / 64.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.14.2 - /usr/local/bin/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 8.5.0 - /usr/local/bin/npm
Browsers:
Chrome: 100.0.4896.127
Firefox: 100.0
Safari: 15.3
Used Package Manager
yarn
Logs
npx vite --debug
vite:config TS + native esm config loaded in 43.29ms URL {
href: 'file:///sites/vite-sibling-tsconfig/vite/vite.config.ts',
origin: 'null',
protocol: 'file:',
username: '',
password: '',
host: '',
hostname: '',
port: '',
pathname: '/sites/vite-sibling-tsconfig/vite/vite.config.ts',
search: '',
searchParams: URLSearchParams {},
hash: ''
} +0ms
vite:vite-plugin-svelte findSvelteDependencies: searching svelte dependencies in /sites/vite-sibling-tsconfig/vite +0ms
vite:vite-plugin-svelte adding bare svelte packages to optimizeDeps.include: svelte/animate, svelte/easing, svelte/internal, svelte/motion, svelte/store, svelte/transition, svelte +1ms
vite:vite-plugin-svelte automatically excluding found svelte dependencies: +0ms
vite:vite-plugin-svelte reincluding transitive dependencies of excluded svelte dependencies [] +0ms
vite:vite-plugin-svelte additional vite config {
resolve: {
mainFields: [ 'svelte', 'module', 'jsnext:main', 'jsnext' ],
dedupe: [
'svelte/animate',
'svelte/easing',
'svelte/internal',
'svelte/motion',
'svelte/ssr',
'svelte/store',
'svelte/transition',
'svelte',
'svelte-hmr/runtime/hot-api-esm.js',
'svelte-hmr/runtime/proxy-adapter-dom.js',
'svelte-hmr'
]
},
optimizeDeps: {
include: [
'svelte/animate',
'svelte/easing',
'svelte/internal',
'svelte/motion',
'svelte/store',
'svelte/transition',
'svelte'
],
exclude: [ 'svelte-hmr' ]
},
ssr: { noExternal: [], external: [] }
} +0ms
vite:vite-plugin-svelte resolved options {
hot: { injectCss: false },
compilerOptions: { css: false, dev: true, format: 'esm' },
extensions: [ '.svelte' ],
emitCss: true,
preprocess: [
{
defaultLanguages: [Object],
markup: [AsyncFunction: markup],
script: [AsyncFunction: script],
style: [AsyncFunction: style]
},
{ style: [Function: style] }
],
configFile: '/sites/vite-sibling-tsconfig/vite/svelte.config.js',
experimental: {},
root: '/sites/vite-sibling-tsconfig/vite',
isBuild: false,
isServe: true,
isDebug: true,
isProduction: false
} +3ms
vite:config using resolved config: {
vite:config plugins: [
vite:config 'vite:pre-alias',
vite:config 'alias',
vite:config 'vite-plugin-svelte',
vite:config 'vite:modulepreload-polyfill',
vite:config 'vite:resolve',
vite:config 'vite:optimized-deps',
vite:config 'vite:html-inline-proxy',
vite:config 'vite:css',
vite:config 'vite:esbuild',
vite:config 'vite:json',
vite:config 'vite:wasm',
vite:config 'vite:worker',
vite:config 'vite:asset',
vite:config 'vite:define',
vite:config 'vite:css-post',
vite:config 'vite:worker-import-meta-url',
vite:config 'vite:client-inject',
vite:config 'vite:import-analysis'
vite:config ],
vite:config resolve: {
vite:config dedupe: [
vite:config 'svelte/animate',
vite:config 'svelte/easing',
vite:config 'svelte/internal',
vite:config 'svelte/motion',
vite:config 'svelte/ssr',
vite:config 'svelte/store',
vite:config 'svelte/transition',
vite:config 'svelte',
vite:config 'svelte-hmr/runtime/hot-api-esm.js',
vite:config 'svelte-hmr/runtime/proxy-adapter-dom.js',
vite:config 'svelte-hmr'
vite:config ],
vite:config alias: [ [Object], [Object], [Object] ],
vite:config mainFields: [ 'svelte', 'module', 'jsnext:main', 'jsnext' ]
vite:config },
vite:config server: {
vite:config preTransformRequests: true,
vite:config fs: { strict: true, allow: [Array], deny: [Array] }
vite:config },
vite:config optimizeDeps: {
vite:config include: [
vite:config 'svelte/animate',
vite:config 'svelte/easing',
vite:config 'svelte/internal',
vite:config 'svelte/motion',
vite:config 'svelte/store',
vite:config 'svelte/transition',
vite:config 'svelte'
vite:config ],
vite:config exclude: [ 'svelte-hmr' ],
vite:config esbuildOptions: { keepNames: undefined, preserveSymlinks: undefined }
vite:config },
vite:config ssr: { noExternal: [], external: [] },
vite:config configFile: '/sites/vite-sibling-tsconfig/vite/vite.config.ts',
vite:config configFileDependencies: [ '/sites/vite-sibling-tsconfig/vite/vite.config.ts' ],
vite:config inlineConfig: {
vite:config root: undefined,
vite:config base: undefined,
vite:config mode: undefined,
vite:config configFile: undefined,
vite:config logLevel: undefined,
vite:config clearScreen: undefined,
vite:config server: {}
vite:config },
vite:config root: '/sites/vite-sibling-tsconfig/vite',
vite:config base: '/',
vite:config publicDir: '/sites/vite-sibling-tsconfig/vite/public',
vite:config cacheDir: '/sites/vite-sibling-tsconfig/vite/node_modules/.vite',
vite:config command: 'serve',
vite:config mode: 'development',
vite:config isWorker: false,
vite:config isProduction: false,
vite:config build: {
vite:config target: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
vite:config polyfillModulePreload: true,
vite:config outDir: 'dist',
vite:config assetsDir: 'assets',
vite:config assetsInlineLimit: 4096,
vite:config cssCodeSplit: true,
vite:config cssTarget: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
vite:config sourcemap: false,
vite:config rollupOptions: {},
vite:config minify: 'esbuild',
vite:config terserOptions: {},
vite:config write: true,
vite:config emptyOutDir: null,
vite:config manifest: false,
vite:config lib: false,
vite:config ssr: false,
vite:config ssrManifest: false,
vite:config reportCompressedSize: true,
vite:config chunkSizeWarningLimit: 500,
vite:config watch: null,
vite:config commonjsOptions: { include: [Array], extensions: [Array] },
vite:config dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] }
vite:config },
vite:config preview: {
vite:config port: undefined,
vite:config strictPort: undefined,
vite:config host: undefined,
vite:config https: undefined,
vite:config open: undefined,
vite:config proxy: undefined,
vite:config cors: undefined,
vite:config headers: undefined
vite:config },
vite:config env: { BASE_URL: '/', MODE: 'development', DEV: true, PROD: false },
vite:config assetsInclude: [Function: assetsInclude],
vite:config logger: {
vite:config hasWarned: false,
vite:config info: [Function: info],
vite:config warn: [Function: warn],
vite:config warnOnce: [Function: warnOnce],
vite:config error: [Function: error],
vite:config clearScreen: [Function: clearScreen],
vite:config hasErrorLogged: [Function: hasErrorLogged]
vite:config },
vite:config packageCache: Map(0) {},
vite:config createResolver: [Function: createResolver],
vite:config worker: {
vite:config format: 'iife',
vite:config plugins: [
vite:config [Object], [Object],
vite:config [Object], [Object],
vite:config [Object], [Object],
vite:config [Object], [Object],
vite:config [Object], [Object],
vite:config [Object], [Object],
vite:config [Object], [Object],
vite:config [Object], [Object],
vite:config [Object]
vite:config ],
vite:config rollupOptions: {}
vite:config }
vite:config } +11ms
vite:deps Hash is consistent. Skipping. Use --force to override. +0ms
Port 3000 is in use, trying another one...
vite v2.9.6 dev server running at:
> Local: http://localhost:3001/
> Network: use `--host` to expose
ready in 112ms.
vite:resolve 2.48ms /service-worker.js -> null +0ms
vite:spa-fallback Not rewriting GET /service-worker.js because the path includes a dot (.) character. +0ms
vite:time 10.28ms /service-worker.js +0ms
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
@sapphi-red -- brilliant, yes, that fixes it for our use case!
gristow push gristow/vite-sibling-tsconfig
commit sha: 0e89b23254a522c0f0245b2ed5fb5f76c7d3dfa9
push time in 2 weeks agogristow issue vitejs/vite
tsconfig fies ignored when importing ts files from sibling directories
Describe the bug
When importing a typescript file from a sibling directory to the vite directory, whether by relative imports or via an alias, neither the tsconfig.json settings of the vite directory nor of the sibling directory are applied.
To reproduce:
- clone the repo:
git clone https://github.com/gristow/vite-sibling-tsconfig.git
- run
yarn
ornpm i
in thevite
subdirectory - run
yarn
ornpm i
in thesibling
directory. - run
yarn dev
ornpm run dev
in thevite
subdirectory.
In this demonstration, identical files (./vite/src/lib/mobxNonSiblingDemo and ./sibling/src/mobxSiblingDemo) are imported into App.svelte.
The tsconfig compilerOptions.useDefineForClassFields
is respected and compiled correctly for the file in the vite/src/lib
directory, but not for the one in the sibling/src
directory. As a result, it becomes impossible to observe certain properties on mobx stores.
Relevant Files:
vite-sibling-tsconfig (root)
└───vite
│ └──src
│ │- App.svelte
│ │
│ └──lib
│ │- mobxNonSiblingDemo.ts
│
└───sibling
└──src
│ │- mobxSiblingDemo.ts
│
│- tsconfig.json
Reproduction
https://github.com/gristow/vite-sibling-tsconfig
System Info
System:
OS: macOS 12.2.1
CPU: (10) arm64 Apple M1 Max
Memory: 11.68 GB / 64.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.14.2 - /usr/local/bin/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 8.5.0 - /usr/local/bin/npm
Browsers:
Chrome: 100.0.4896.127
Firefox: 100.0
Safari: 15.3
Used Package Manager
yarn
Logs
npx vite --debug
vite:config TS + native esm config loaded in 43.29ms URL {
href: 'file:///sites/vite-sibling-tsconfig/vite/vite.config.ts',
origin: 'null',
protocol: 'file:',
username: '',
password: '',
host: '',
hostname: '',
port: '',
pathname: '/sites/vite-sibling-tsconfig/vite/vite.config.ts',
search: '',
searchParams: URLSearchParams {},
hash: ''
} +0ms
vite:vite-plugin-svelte findSvelteDependencies: searching svelte dependencies in /sites/vite-sibling-tsconfig/vite +0ms
vite:vite-plugin-svelte adding bare svelte packages to optimizeDeps.include: svelte/animate, svelte/easing, svelte/internal, svelte/motion, svelte/store, svelte/transition, svelte +1ms
vite:vite-plugin-svelte automatically excluding found svelte dependencies: +0ms
vite:vite-plugin-svelte reincluding transitive dependencies of excluded svelte dependencies [] +0ms
vite:vite-plugin-svelte additional vite config {
resolve: {
mainFields: [ 'svelte', 'module', 'jsnext:main', 'jsnext' ],
dedupe: [
'svelte/animate',
'svelte/easing',
'svelte/internal',
'svelte/motion',
'svelte/ssr',
'svelte/store',
'svelte/transition',
'svelte',
'svelte-hmr/runtime/hot-api-esm.js',
'svelte-hmr/runtime/proxy-adapter-dom.js',
'svelte-hmr'
]
},
optimizeDeps: {
include: [
'svelte/animate',
'svelte/easing',
'svelte/internal',
'svelte/motion',
'svelte/store',
'svelte/transition',
'svelte'
],
exclude: [ 'svelte-hmr' ]
},
ssr: { noExternal: [], external: [] }
} +0ms
vite:vite-plugin-svelte resolved options {
hot: { injectCss: false },
compilerOptions: { css: false, dev: true, format: 'esm' },
extensions: [ '.svelte' ],
emitCss: true,
preprocess: [
{
defaultLanguages: [Object],
markup: [AsyncFunction: markup],
script: [AsyncFunction: script],
style: [AsyncFunction: style]
},
{ style: [Function: style] }
],
configFile: '/sites/vite-sibling-tsconfig/vite/svelte.config.js',
experimental: {},
root: '/sites/vite-sibling-tsconfig/vite',
isBuild: false,
isServe: true,
isDebug: true,
isProduction: false
} +3ms
vite:config using resolved config: {
vite:config plugins: [
vite:config 'vite:pre-alias',
vite:config 'alias',
vite:config 'vite-plugin-svelte',
vite:config 'vite:modulepreload-polyfill',
vite:config 'vite:resolve',
vite:config 'vite:optimized-deps',
vite:config 'vite:html-inline-proxy',
vite:config 'vite:css',
vite:config 'vite:esbuild',
vite:config 'vite:json',
vite:config 'vite:wasm',
vite:config 'vite:worker',
vite:config 'vite:asset',
vite:config 'vite:define',
vite:config 'vite:css-post',
vite:config 'vite:worker-import-meta-url',
vite:config 'vite:client-inject',
vite:config 'vite:import-analysis'
vite:config ],
vite:config resolve: {
vite:config dedupe: [
vite:config 'svelte/animate',
vite:config 'svelte/easing',
vite:config 'svelte/internal',
vite:config 'svelte/motion',
vite:config 'svelte/ssr',
vite:config 'svelte/store',
vite:config 'svelte/transition',
vite:config 'svelte',
vite:config 'svelte-hmr/runtime/hot-api-esm.js',
vite:config 'svelte-hmr/runtime/proxy-adapter-dom.js',
vite:config 'svelte-hmr'
vite:config ],
vite:config alias: [ [Object], [Object], [Object] ],
vite:config mainFields: [ 'svelte', 'module', 'jsnext:main', 'jsnext' ]
vite:config },
vite:config server: {
vite:config preTransformRequests: true,
vite:config fs: { strict: true, allow: [Array], deny: [Array] }
vite:config },
vite:config optimizeDeps: {
vite:config include: [
vite:config 'svelte/animate',
vite:config 'svelte/easing',
vite:config 'svelte/internal',
vite:config 'svelte/motion',
vite:config 'svelte/store',
vite:config 'svelte/transition',
vite:config 'svelte'
vite:config ],
vite:config exclude: [ 'svelte-hmr' ],
vite:config esbuildOptions: { keepNames: undefined, preserveSymlinks: undefined }
vite:config },
vite:config ssr: { noExternal: [], external: [] },
vite:config configFile: '/sites/vite-sibling-tsconfig/vite/vite.config.ts',
vite:config configFileDependencies: [ '/sites/vite-sibling-tsconfig/vite/vite.config.ts' ],
vite:config inlineConfig: {
vite:config root: undefined,
vite:config base: undefined,
vite:config mode: undefined,
vite:config configFile: undefined,
vite:config logLevel: undefined,
vite:config clearScreen: undefined,
vite:config server: {}
vite:config },
vite:config root: '/sites/vite-sibling-tsconfig/vite',
vite:config base: '/',
vite:config publicDir: '/sites/vite-sibling-tsconfig/vite/public',
vite:config cacheDir: '/sites/vite-sibling-tsconfig/vite/node_modules/.vite',
vite:config command: 'serve',
vite:config mode: 'development',
vite:config isWorker: false,
vite:config isProduction: false,
vite:config build: {
vite:config target: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
vite:config polyfillModulePreload: true,
vite:config outDir: 'dist',
vite:config assetsDir: 'assets',
vite:config assetsInlineLimit: 4096,
vite:config cssCodeSplit: true,
vite:config cssTarget: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
vite:config sourcemap: false,
vite:config rollupOptions: {},
vite:config minify: 'esbuild',
vite:config terserOptions: {},
vite:config write: true,
vite:config emptyOutDir: null,
vite:config manifest: false,
vite:config lib: false,
vite:config ssr: false,
vite:config ssrManifest: false,
vite:config reportCompressedSize: true,
vite:config chunkSizeWarningLimit: 500,
vite:config watch: null,
vite:config commonjsOptions: { include: [Array], extensions: [Array] },
vite:config dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] }
vite:config },
vite:config preview: {
vite:config port: undefined,
vite:config strictPort: undefined,
vite:config host: undefined,
vite:config https: undefined,
vite:config open: undefined,
vite:config proxy: undefined,
vite:config cors: undefined,
vite:config headers: undefined
vite:config },
vite:config env: { BASE_URL: '/', MODE: 'development', DEV: true, PROD: false },
vite:config assetsInclude: [Function: assetsInclude],
vite:config logger: {
vite:config hasWarned: false,
vite:config info: [Function: info],
vite:config warn: [Function: warn],
vite:config warnOnce: [Function: warnOnce],
vite:config error: [Function: error],
vite:config clearScreen: [Function: clearScreen],
vite:config hasErrorLogged: [Function: hasErrorLogged]
vite:config },
vite:config packageCache: Map(0) {},
vite:config createResolver: [Function: createResolver],
vite:config worker: {
vite:config format: 'iife',
vite:config plugins: [
vite:config [Object], [Object],
vite:config [Object], [Object],
vite:config [Object], [Object],
vite:config [Object], [Object],
vite:config [Object], [Object],
vite:config [Object], [Object],
vite:config [Object], [Object],
vite:config [Object], [Object],
vite:config [Object]
vite:config ],
vite:config rollupOptions: {}
vite:config }
vite:config } +11ms
vite:deps Hash is consistent. Skipping. Use --force to override. +0ms
Port 3000 is in use, trying another one...
vite v2.9.6 dev server running at:
> Local: http://localhost:3001/
> Network: use `--host` to expose
ready in 112ms.
vite:resolve 2.48ms /service-worker.js -> null +0ms
vite:spa-fallback Not rewriting GET /service-worker.js because the path includes a dot (.) character. +0ms
vite:time 10.28ms /service-worker.js +0ms
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
gristow push gristow/svelte-mobx-failure
commit sha: 84e9ce9e7ce20fd180ef2bf2e6ab9fba5b72cc9a
push time in 3 weeks agogristow issue prisma/prisma
Client crash on out-of-range integer update using Postgres
Bug description
When working with postgres integer columns, certain javascript numerical values produce unexpected results or even cause a full client crash.
- Attempting to update an integer column to 32e100 (out of range) causes a full client crash
- Attempting to update an integer to 2147483649 (out of range by 2) causes a wrap around to -2147483647
How to reproduce
A minimal reproduction is available at https://github.com/gristow/prisma-int-overflow
schema.prisma
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Integer {
id Int @id @default(autoincrement())
integer Int @default(1)
}
To reproduce client crash:
const firstRecord = await prisma.integer.create({
data: {
integer: 1,
},
});
// This is well outside the limit for a Postgres integer type.
const newIntegerValue = 32e100;
// This update should throw an error, ideally an "integer out of
// range" error, as Postgres would. Instead, it crashes the
// prisma client.
await prisma.integer.update({
where: {
id: firstRecord.id,
},
data: {
integer: 32e100,
},
});
To reproduce the unexpected integer wrap-around:
const record = await prisma.integer.create({
data: {
integer: 1,
},
});
// The max value for a PG integer is 2147483647. This value is intentionally
// too large.
const newIntegerValue = 2147483649;
// This update should throw an error -- ideally an "integer out of range" error
// as postgres would directly. But it throws no error.
await prisma.integer.update({
where: {
id: record.id,
},
data: {
integer: newIntegerValue,
},
});
const updatedRecord = await prisma.integer.findUnique({
where: {
id: record.id,
},
});
// Instead, the value is set to the negative wrap-around.
assert(
newIntegerValue === updatedRecord?.integer,
`Expected ${updatedRecord?.integer} to be ${newIntegerValue}`
);
Expected behavior
When attempting to update an integer column with a value that is outside of the acceptable ranges, the Prisma client should return an error, ideally one that indicates that the integer is out of range, as Postgres does natively.
Prisma information
See steps to reproduce above.
Environment & setup
MacOS 12.2.1 Prisma 3.12.0 PostgreSQL 12.8 (Debian 12.8-1.pgdg110+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit Node 16.12.0
Prisma Version
prisma : 3.12.0
@prisma/client : 3.12.0
Current platform : darwin
Query Engine (Node-API) : libquery-engine 22b822189f46ef0dc5c5b503368d1bee01213980 (at node_modules/@prisma/engines/libquery_engine-darwin.dylib.node)
Migration Engine : migration-engine-cli 22b822189f46ef0dc5c5b503368d1bee01213980 (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core 22b822189f46ef0dc5c5b503368d1bee01213980 (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary : prisma-fmt 22b822189f46ef0dc5c5b503368d1bee01213980 (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash : 22b822189f46ef0dc5c5b503368d1bee01213980
Studio : 0.459.0
Preview Features : filterJson
gristow push gristow/prisma-int-overflow
commit sha: b848689b0d4488a87e2941abfc1f570271d92311
push time in 3 weeks agogristow issue comment 0xfe/vexflow
Input events
Is there any plan to support events (such as hover, click, and tap events) within VexFlow? It could be useful for building music composition apps or music theory games!
(Also, VexFlow is incredible. Really amazing work. 👍)
Sorry -- I have no idea what soundtrack.sheetContext
is, that's not part of the VexFlow code base, so I can't help with its being undefined.
gristow issue comment 0xfe/vexflow
Input events
Is there any plan to support events (such as hover, click, and tap events) within VexFlow? It could be useful for building music composition apps or music theory games!
(Also, VexFlow is incredible. Really amazing work. 👍)
@stephaneeybert -- it looks like there's an error in your svgXToBrowser and svgYToBrowser functions. The browser click event and SVG coordinates are different both in terms of origin and scale. So, you'll need to use a matrix transform.
See this stack overflow or the getCoords function in this fiddle.
gristow issue comment 0xfe/vexflow
Input events
Is there any plan to support events (such as hover, click, and tap events) within VexFlow? It could be useful for building music composition apps or music theory games!
(Also, VexFlow is incredible. Really amazing work. 👍)
@stephaneeybert the fiddle being down is related to #1354, I've fixed the fiddle so it runs again.
Do I need to create a bounding box with top, left, bottom, right coordinates for each note and then traverse all the notes of the soundtrack to find the one matching the click coordinates ?
Yes, this is the general approach. I memoize the bounding boxes on each render of a score into an array with pointers to the object in question, myself. At the moment I just iterate over the array finding matching coordinates. The lookup time is negligible. If you have such a huge number of elements that lookup time is significant, you could memoize as an array sorted by x or y, and then use a binary search. (Though, I really think the lookup is unlikely to be the performance bottleneck.)
gristow issue comment 0xfe/vexflow
4.1.0
@0xfe @ronyeh @AaronDavidNewman @mscuthbert @gristow @sschmidTU what would you like to see in 4.1.x? Understood 4.0.2 will be bug fix.
The main thing I've run into so far is that some of the horizontal note spacings seem odd in 4.0.1 when a measure has more available space than is needed for the notes. For instance, here the eighth notes feel quite squished in:
import Vex from './node_modules/vexflow/build/esm/entry/vexflow-debug.js';
const staveWidth = 200;
const ctx = Vex.Flow.Renderer.getSVGContext('output', staveWidth + 50, 500);
const stave = new Vex.Flow.Stave(10, 50, staveWidth)
.addClef('treble')
.addTimeSignature('2/4')
.setEndBarType(Vex.Flow.Barline.type.END);
const notes = [
new Vex.Flow.StaveNote({ keys: ['c/4'], duration: '4' }),
new Vex.Flow.StaveNote({ keys: ['d/4'], duration: '8' }),
new Vex.Flow.StaveNote({ keys: ['e/4'], duration: '8' }),
];
const beam = new Vex.Flow.Beam(notes.slice(1), { autoStem: true });
notes.forEach((note) => note.setStave(stave));
const voice = new Vex.Flow.Voice(Vex.Flow.TIME2_4)
.setMode(Vex.Flow.Voice.Mode.FULL)
.addTickables(notes);
new Vex.Flow.Formatter()
.joinVoices([voice])
.formatToStave([voice], stave);
stave.setContext(ctx).draw();
voice.draw(ctx);
beam.setContext(ctx).draw();
Unfortunately, I'm really not familiar enough with the formatter code to make an attempt at improving this... but it would definitely be on my wish list!
gristow issue comment 0xfe/vexflow
4.0.1
@0xfe @ronyeh @AaronDavidNewman @mscuthbert @sschmidTU @h-sug1no HappyNew Year! :)
I would like to start a discussion on when to release a 4.0.1. I would suggest to close #1155 this issue is already quite long. There are mainly two topics that I can think of:
- beta or release
- content
Looks good to me -- thanks for the amazing work on this @ronyeh!
gristow merge to 0xfe/vexflow
feat(StaveConnector) add getType(), tighten setType() typings
This PR:
- Adds a
getType()
method to match the existingsetType()
method onStaveConnector
- Tightens the parameters definition on
setType()
to use a union of acceptable types, instead of all strings and numbers. (This also improves intellisense completion, see below.)
Previously:
After Change:
gristow wants to merge 0xfe/vexflow
feat(StaveConnector) add getType(), tighten setType() typings
This PR:
- Adds a
getType()
method to match the existingsetType()
method onStaveConnector
- Tightens the parameters definition on
setType()
to use a union of acceptable types, instead of all strings and numbers. (This also improves intellisense completion, see below.)
Previously:
After Change:
@0xfe --just pushed a revision that makes the StaveConnectorType definition cleaner and sets the types of StaveConnector.type and StaveConnector.typeString by using the StaveConnectorType
definition, rather than the other way around. Hopefully it's a lot more readable/grokkable.
gristow push gristow/vexflow
commit sha: d605a95a163faf8cc8b497598ae0efc70fb4820b
push time in 1 month agogristow issue comment 0xfe/vexflow
Make the CJS and ESM builds export the same thing.
Huge thanks to @gristow for discovering that our CJS and ESM builds don't quite export the same thing. :-D
I'm still working on it, but I think we can have a clean solution for this. The actual files we need to modify are in vexflow/entry/
because those are the entry files for the various libs that are produced by webpack (CJS). Those are also the entry files that will be compiled by TypeScript compiler into ESM entry files. See the exports
field in package.json
for a list of all the entry files for require / import.
In this PR, I will clean up src/index.ts
to no longer have a default export. For compatibility & flexibility, all the entry files will have both named exports and a default export. Additionally, we will verify that CJS and ESM code can both import modules in the same manner (e.g., a named import of StaveNote
).
I will update you all when there's a build you can test with!
I built and tested this out on the dev branch of uTheory this afternoon -- it works beautifully in both the ESM & CJS contexts, and I like the cleanliness of using all named exports in src/index.ts, too. Looks good to me!
gristow issue comment 0xfe/vexflow
Make the CJS and ESM builds export the same thing.
Huge thanks to @gristow for discovering that our CJS and ESM builds don't quite export the same thing. :-D
I'm still working on it, but I think we can have a clean solution for this. The actual files we need to modify are in vexflow/entry/
because those are the entry files for the various libs that are produced by webpack (CJS). Those are also the entry files that will be compiled by TypeScript compiler into ESM entry files. See the exports
field in package.json
for a list of all the entry files for require / import.
In this PR, I will clean up src/index.ts
to no longer have a default export. For compatibility & flexibility, all the entry files will have both named exports and a default export. Additionally, we will verify that CJS and ESM code can both import modules in the same manner (e.g., a named import of StaveNote
).
I will update you all when there's a build you can test with!
Thanks, @ronyeh! I'll do some testing this afternoon/evening!
gristow push gristow/vexflow
commit sha: 97d233428208067cb8cd9ec81157be4c081e09a5
push time in 2 months agogristow issue 0xfe/vexflow
CJS/ESM Build Alignment
The output of the CJS and ESM builds from src/index.ts
have different shapes because the default export of Vex in src/index.ts
clobbers the named exports from the same file in the Webpack UMD build process.
As a result, when working in an ESM context this will work:
import { StaveNote } from 'vexflow';
const sn = new StaveNote();
But the parallel CJS code will not work:
const StaveNote = require('vexflow').StaveNote;
const sn = new StaveNote(); // Uncaught Reference Error: StaveNote is not defined
I'm hitting this issue, personally, using Vite which transforms ESM import style code to CJS require style code in node to provide the server-side render. (And I would guess given the rise in SSR frameworks we'll soon see others with similar issues.)
A quick fix would be to merge Flow onto the default export in src/index.ts
:
// Export Vex as a named export AND as a default export, to support both ways of importing.
export { Vex };
export default {
...Vex,
...Flow,
};
This alters the default export to become an object, instead of the Vex class -- but, since we only use static props on the Vex class anyway, this doesn't break any tests. (And it shouldn't break any implementations.)
Thoughts? (Especially @ronyeh since you did the bulk of the ESM build work.)
I've got a working branch with these changes -- but will hold off on a PR unless/until we think this makes sense as a way to go.
gristow pull request bevacqua/dragula
fix #447: Remove root references to document
Moves references to document within functions so that dragula can be required/imported in a non-browser context. Fixes #447.
gristow push gristow/dragon-drop
commit sha: 677a79f1013f01e82867c888aaa8850c8197e4e2
push time in 2 months ago
Client crash on out-of-range integer update using Postgres
Bug description
When working with postgres integer columns, certain javascript numerical values produce unexpected results or even cause a full client crash.
How to reproduce
A minimal reproduction is available at https://github.com/gristow/prisma-int-overflow
schema.prisma
To reproduce client crash:
To reproduce the unexpected integer wrap-around:
Expected behavior
When attempting to update an integer column with a value that is outside of the acceptable ranges, the Prisma client should return an error, ideally one that indicates that the integer is out of range, as Postgres does natively.
Prisma information
See steps to reproduce above.
Environment & setup
MacOS 12.2.1 Prisma 3.12.0 PostgreSQL 12.8 (Debian 12.8-1.pgdg110+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit Node 16.12.0
Prisma Version