diff --git a/packages/less/build/browser-dev.mjs b/packages/less/build/browser-dev.mjs index a1f60be6fa..d0709051f8 100644 --- a/packages/less/build/browser-dev.mjs +++ b/packages/less/build/browser-dev.mjs @@ -54,7 +54,7 @@ const result = await esbuild.build({ banner: { js: '/*! Less v5 (alpha) browser build. For live styling in the browser, follow the Less browser guide. Compiling Less in the browser is not intended for production — compile ahead of time (Node "less") for production builds. */\n' + - 'var process = (typeof globalThis !== "undefined" && globalThis.process) || { env: {}, cwd: function () { return "/"; }, argv: [], platform: "browser" };' + 'var process = (typeof globalThis !== "undefined" && globalThis.process) || { env: {}, cwd: function () { return "/"; }, argv: [], platform: "browser", stderr: {}, stdout: {} };' }, alias: { fs: join(stubs, 'fs.js'), diff --git a/packages/less/lib/index.js b/packages/less/lib/index.js index 0983d3ec31..7eda5d91bf 100644 --- a/packages/less/lib/index.js +++ b/packages/less/lib/index.js @@ -12,7 +12,7 @@ import { readFileSync } from 'node:fs'; import { readFile } from 'node:fs/promises'; import { Compiler } from '@jesscss/compiler'; -import nodeModulesPlugin from '@jesscss/plugin-node-modules'; +import { LessCompiler } from './less-compiler.js'; import { createLessOptions, getCompilerCacheKey, mapRenderResult } from './options.js'; import { version } from './version.js'; import { logger } from './logger.js'; @@ -71,11 +71,7 @@ function getCompiler(configOptions) { const cacheKey = getCompilerCacheKey(configOptions); let compiler = compilerCache.get(cacheKey); if (!compiler) { - compiler = new Compiler(configOptions, { - defaultPlugins: context => [nodeModulesPlugin({ basePath: context.resolutionBaseDir })], - scriptPluginSpecifier: '@jesscss/plugin-js', - scriptPluginResolveFrom: import.meta.url - }); + compiler = new LessCompiler(configOptions); compilerCache.set(cacheKey, compiler); } return compiler; diff --git a/packages/less/lib/less-compiler.js b/packages/less/lib/less-compiler.js new file mode 100644 index 0000000000..671700a74e --- /dev/null +++ b/packages/less/lib/less-compiler.js @@ -0,0 +1,27 @@ +import { Compiler } from '@jesscss/compiler'; +import nodeModulesPlugin from '@jesscss/plugin-node-modules'; + +/** + * The compiler `less.render()` runs: the Jess compiler with Less's default + * plugins. It names its own module, so a render that reaches a `@plugin` + * script runs whole in the `@jesscss/plugin-js` sandbox with this same + * compiler, made there from this module. + */ +export class LessCompiler extends Compiler { + /* + * Spelled relative to `lib/` so it names this file from the ESM entry and + * from the bundled CommonJS build in `dist/` alike. + */ + static moduleIdentity = { module: new URL('../lib/less-compiler.js', import.meta.url).href, exportName: 'LessCompiler' }; + + /** + * @param {object} configOptions + */ + constructor(configOptions) { + super(configOptions, { + defaultPlugins: context => [nodeModulesPlugin({ basePath: context.resolutionBaseDir })], + scriptPluginSpecifier: '@jesscss/plugin-js', + scriptPluginResolveFrom: import.meta.url + }); + } +} diff --git a/packages/less/package.json b/packages/less/package.json index 918efb92d5..4514c76e09 100644 --- a/packages/less/package.json +++ b/packages/less/package.json @@ -53,7 +53,7 @@ }, "scripts": { "quicktest": "npm run test:legacy-node", - "test:alpha": "npm run typecheck && npm run build && npm run test:lessc && node test/jess-alpha-fast-path.mjs && node test/alpha-support.mjs && node test/alpha-sourcemaps.mjs && node test/alpha-fixtures.mjs", + "test:alpha": "npm run typecheck && npm run build && npm run test:lessc && node test/jess-alpha-fast-path.mjs && node test/alpha-support.mjs && node test/alpha-sourcemaps.mjs && node test/alpha-fixtures.mjs && npm run build:browser && node test/alpha-browser-bundle.mjs", "test:lessc": "node test/lessc-alpha.mjs", "test": "npm run test:alpha", "test:module": "node test/test-es6.js && node test/test-cjs.cjs", @@ -142,15 +142,15 @@ "rawcurrent": "https://raw.github.com/less/less.js/v", "sourcearchive": "https://github.com/less/less.js/archive/v", "dependencies": { - "@jesscss/compiler": "2.0.0-alpha.31", - "@jesscss/core": "2.0.0-alpha.31", - "@jesscss/plugin-less": "2.0.0-alpha.31", - "@jesscss/plugin-less-compat": "2.0.0-alpha.31", - "@jesscss/plugin-node-modules": "2.0.0-alpha.31", + "@jesscss/compiler": "2.0.0-alpha.32", + "@jesscss/core": "2.0.0-alpha.32", + "@jesscss/plugin-less": "2.0.0-alpha.32", + "@jesscss/plugin-less-compat": "2.0.0-alpha.32", + "@jesscss/plugin-node-modules": "2.0.0-alpha.32", "parse-node-version": "^1.0.1" }, "peerDependencies": { - "@jesscss/plugin-js": "2.0.0-alpha.31" + "@jesscss/plugin-js": "2.0.0-alpha.32" }, "peerDependenciesMeta": { "@jesscss/plugin-js": { diff --git a/packages/less/test/alpha-browser-bundle.mjs b/packages/less/test/alpha-browser-bundle.mjs new file mode 100644 index 0000000000..2425292127 --- /dev/null +++ b/packages/less/test/alpha-browser-bundle.mjs @@ -0,0 +1,32 @@ +/** + * Loads the built `dist/less-browser-dev.js` in a context with browser globals + * and no Node `process`, then renders through `window.less`. Run `build:browser` + * first. + */ +import assert from 'node:assert/strict'; +import { readFileSync } from 'node:fs'; +import vm from 'node:vm'; + +const bundle = readFileSync(new URL('../dist/less-browser-dev.js', import.meta.url), 'utf8'); + +const window = { + location: { href: 'http://localhost/' }, + document: {}, + console, + setTimeout, + clearTimeout, + URL, + TextEncoder, + TextDecoder, + queueMicrotask, + performance +}; +window.window = window; +window.globalThis = window; +window.self = window; + +vm.runInContext(bundle, vm.createContext(window)); + +const { css } = await window.less.render('.m() { x: 1; }\n.a { b: (1 + 1); .m(); &:hover { c: contrast(#f00); } }\n'); +assert.equal(css, '.a {\n b: 2;\n x: 1;\n &:hover {\n c: #000000;\n }\n}\n'); +console.log('Less browser bundle render passed'); diff --git a/packages/less/test/alpha-fixtures.mjs b/packages/less/test/alpha-fixtures.mjs index c691627e81..895eecd4a3 100644 --- a/packages/less/test/alpha-fixtures.mjs +++ b/packages/less/test/alpha-fixtures.mjs @@ -122,7 +122,6 @@ const expectedFailureFixtures = new Map([ ['tests-unit/plugin-module/plugin-module.less', 'legacy CommonJS @plugin graph with require() is not supported by the optional JS runtime'], ['tests-unit/plugin-preeval/plugin-preeval.less', 'legacy tree visitor ABI is not supported'], ['tests-unit/plugin/plugin.less', '@plugin scripts execute; the Less 4 golden uses the deprecated registerPlugin/(option) lifecycle and flattened output. v5 intentionally does NOT merge nested @media (nesting is preserved by design), so that is not a gap'], - ['tests-unit/parse-interpolation/parse-interpolation.less', 'renders but interpolation formatting differs from Less'], ['tests-unit/parser-slashed-combinator/parser-slashed-combinator.less', 'slashed combinator not yet supported'], ['tests-unit/permissive-parse/permissive-parse.less', 'permissive legacy parser corners are not alpha-supported'], ['tests-unit/media/media.less', 'top-level bare @var at-rule preludes are rejected'], diff --git a/packages/test-data/tests-config/math/parens-division/mixins-args.css b/packages/test-data/tests-config/math/parens-division/mixins-args.css index 82407441e0..5ee81e7a98 100644 --- a/packages/test-data/tests-config/math/parens-division/mixins-args.css +++ b/packages/test-data/tests-config/math/parens-division/mixins-args.css @@ -24,7 +24,7 @@ .var-args { width: 45; height: 8%; - depth: 18 / 2 - 1%; + depth: 8%; } .multi-mix { width: 10px; diff --git a/packages/test-data/tests-config/math/parens-division/parens.css b/packages/test-data/tests-config/math/parens-division/parens.css index bfd332733c..ddd89c14ac 100644 --- a/packages/test-data/tests-config/math/parens-division/parens.css +++ b/packages/test-data/tests-config/math/parens-division/parens.css @@ -21,7 +21,7 @@ margin-keep: 12; margin-parts: 12; margin-all: 12; - border-radius-keep: 8px / 7px; + border-radius-keep: 4px * 2 / 4 + 3px; border-radius-parts: 8px / 7px; border-radius-all: 5px; } diff --git a/packages/test-data/tests-unit/functions/functions.css b/packages/test-data/tests-unit/functions/functions.css index b303058a24..6de394b463 100644 --- a/packages/test-data/tests-unit/functions/functions.css +++ b/packages/test-data/tests-unit/functions/functions.css @@ -30,7 +30,7 @@ saturate-filter: saturate(5%); contrast-white: #000000; contrast-black: #ffffff; - contrast-red: #ffffff; + contrast-red: #000000; contrast-green: #000000; contrast-blue: #ffffff; contrast-yellow: #000000; diff --git a/packages/test-data/tests-unit/math-css-vars/math-css-vars.css b/packages/test-data/tests-unit/math-css-vars/math-css-vars.css index 6bba2fd863..80ff7d93a2 100644 --- a/packages/test-data/tests-unit/math-css-vars/math-css-vars.css +++ b/packages/test-data/tests-unit/math-css-vars/math-css-vars.css @@ -3,7 +3,7 @@ b: cos(var(--a)); c: calc(tan(var(--t)) * 1px); d: atan2(var(--x), var(--y)); - e: percentage(var(--p)); + e: calc(var(--p) * 100%); } .numeric { a: 0.5; diff --git a/packages/test-data/tests-unit/operations/operations-advanced.css b/packages/test-data/tests-unit/operations/operations-advanced.css index ab78ebb9cc..f26cef54d5 100644 --- a/packages/test-data/tests-unit/operations/operations-advanced.css +++ b/packages/test-data/tests-unit/operations/operations-advanced.css @@ -8,7 +8,7 @@ result: #ff0a0a; } .test-division { - result: calc(10px / 2 * 2); + result: 10px; } .test-nested { result: 30px; diff --git a/packages/test-data/tests-unit/parse-interpolation/parse-interpolation.css b/packages/test-data/tests-unit/parse-interpolation/parse-interpolation.css index 5599e29187..846ff8f81c 100644 --- a/packages/test-data/tests-unit/parse-interpolation/parse-interpolation.css +++ b/packages/test-data/tests-unit/parse-interpolation/parse-interpolation.css @@ -24,7 +24,8 @@ input[type=text], input[type=email], input[type=password], textarea { } } .bar { - .d:is(.a, .b, .c)&:hover, baz-cap { + .d:is(.a, .b, .c)&:hover, + baz-cap { color: blue; } } @@ -41,7 +42,7 @@ input[type=text], input[type=email], input[type=password], textarea { } .a, .b.c, .d { + .e-quoted { - foo: bar; + foo: baz; } } input.cap { @@ -66,9 +67,11 @@ input.quoted { background-color: blue; } } -.fruit-cap-apple, -.fruit-cap-satsuma, -.fruit-cap-banana, -.fruit-cap-pear { - content: "Capture"; +apple, +satsuma, +banana, +pear { + .fruit-cap-& { + content: "Capture"; + } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b53a29a9a4..0f78862b46 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -30,20 +30,20 @@ importers: packages/less: dependencies: '@jesscss/compiler': - specifier: 2.0.0-alpha.31 - version: 2.0.0-alpha.31(typescript@5.9.3) + specifier: 2.0.0-alpha.32 + version: 2.0.0-alpha.32(typescript@5.9.3) '@jesscss/core': - specifier: 2.0.0-alpha.31 - version: 2.0.0-alpha.31 + specifier: 2.0.0-alpha.32 + version: 2.0.0-alpha.32 '@jesscss/plugin-less': - specifier: 2.0.0-alpha.31 - version: 2.0.0-alpha.31(typescript@5.9.3) + specifier: 2.0.0-alpha.32 + version: 2.0.0-alpha.32(typescript@5.9.3) '@jesscss/plugin-less-compat': - specifier: 2.0.0-alpha.31 - version: 2.0.0-alpha.31 + specifier: 2.0.0-alpha.32 + version: 2.0.0-alpha.32 '@jesscss/plugin-node-modules': - specifier: 2.0.0-alpha.31 - version: 2.0.0-alpha.31 + specifier: 2.0.0-alpha.32 + version: 2.0.0-alpha.32 parse-node-version: specifier: ^1.0.1 version: 1.0.1 @@ -416,52 +416,52 @@ packages: resolution: {integrity: sha512-+Sg6GCR/wy1oSmQDFq4LQDAhm3ETKnorxN+y5nbLULOR3P0c14f2Wurzj3/xqPXtasLFfHd5iRFQ7AJt4KH2cw==} engines: {node: '>=8'} - '@jesscss/awaitable-pipe@2.0.0-alpha.31': - resolution: {integrity: sha512-C1fdsutgMnTrcwGJ8tNJjhc9xNWgteUgSCWriMKEEsjZo8dJw6j1mszWEFNG3Bps4I7e+AD7qPOF503RREVaGg==} + '@jesscss/awaitable-pipe@2.0.0-alpha.32': + resolution: {integrity: sha512-9O9WrLUXUlIKoMU7lk0zbjM5Q4c/QwZb+752ewBWFyXkge+HTreZbdvnsMhYm6E2wlNwua5NjVn207pf0a7vQg==} engines: {node: ^20.19.0 || >=22.12.0} - '@jesscss/compiler@2.0.0-alpha.31': - resolution: {integrity: sha512-UVNrLWP4MVUF9GFQzUwGsZVbVusK3GS8C3RNWO83t/uUx05jEuQ8/hzvHdvAwjXKvawy0I+DB9PpsHyZBUmTFA==} + '@jesscss/compiler@2.0.0-alpha.32': + resolution: {integrity: sha512-BZzC5BTp9r5PsAUe3KkQRSeaEgwNhqJUgrHXRKjl5UY2xVo2tOLkKUjso7dj/V+AJ7LBP9oahGzjGm17/NhTJQ==} engines: {node: ^20.19.0 || >=22.12.0} - '@jesscss/core@2.0.0-alpha.31': - resolution: {integrity: sha512-/VkOgUzvEYZ6jDnc3KCXoiTMePA3JwulhIqQQ14ntTo7jIpBEI3CXHkZNfUJLjoco6NQ5T7Bs0k5YWey7GCB5w==} + '@jesscss/core@2.0.0-alpha.32': + resolution: {integrity: sha512-CqWugmhbrOAWbxJ3BAmq9ZhJPOsNB53lzwbfUa/rpBsZ29ROyejegUZH+LnucSHhvh7iBhmljWtiAA+hRsU1dg==} engines: {node: ^20.19.0 || >=22.12.0} - '@jesscss/css-parser@2.0.0-alpha.31': - resolution: {integrity: sha512-m5dNH7morFVGzjvY/R6P6FzFyFcdby2Af2m6zvziqKoMbdFBLwzZ8Pm9nZH7HtVo/czrjsG0bnKYLMIGTNldEQ==} + '@jesscss/css-parser@2.0.0-alpha.32': + resolution: {integrity: sha512-hcIDGdeFQQFWAE28D+e+X69oZhLxcCXmB2YAO82mGfPQUcOdKnx3tKfyz/YIRybeiimIqIPcOaBONs+X14OCEg==} engines: {node: ^20.19.0 || >=22.12.0} peerDependencies: - '@jesscss/core': 2.0.0-alpha.31 + '@jesscss/core': 2.0.0-alpha.32 - '@jesscss/fns@2.0.0-alpha.31': - resolution: {integrity: sha512-CQhFIHphO8CQgxj1UjIX2S5t1EFv24xxq22NKfUqqrqwYgn/HXzmX3fJLCBplNYPdfFiPXIxLcys/XDQqr8SzA==} + '@jesscss/fns@2.0.0-alpha.32': + resolution: {integrity: sha512-234vLycgRW0cYc8hU2YdjrgF2+2uA/3U2KgT9CQG11qTjwpFjUMot7wZOStJaU2V73Qg4gUCw4Zu4UP8w55wJg==} engines: {node: ^20.19.0 || >=22.12.0} - '@jesscss/less-parser@2.0.0-alpha.31': - resolution: {integrity: sha512-K3k3LzsHmHApdSPOs/p3BLDSF0sQKw2DCCw5S93HX/RM4a0o0IdpiHxtXv5rX905ONvF/tz9ib6BbsUuKWC47g==} + '@jesscss/less-parser@2.0.0-alpha.32': + resolution: {integrity: sha512-B4Jk/hb3Zu0WdapRnUKSMjpTyLx86yo9H1UWvmg/HnJ3zFzvY4469yaV8sZqpot9iq7JENf82Lw63pqW2YhScw==} engines: {node: ^20.19.0 || >=22.12.0} peerDependencies: - '@jesscss/core': 2.0.0-alpha.31 + '@jesscss/core': 2.0.0-alpha.32 - '@jesscss/parser-shared@2.0.0-alpha.31': - resolution: {integrity: sha512-GBWyfiBbEzB//P2tp9yBhNMbqgnuFXNG7l2FmDDgzqfRqOG6Vi/ITCeNqyYpzqW/GSQRcoVpMZeycyLx2otOeg==} + '@jesscss/parser-shared@2.0.0-alpha.32': + resolution: {integrity: sha512-nhKZBHiWUgNp/MUuOy7f1uBQBvg76etlXWHnmCJmZyt+s4z21HDasY4hIvIV7o9awnqjmtJQTOpuw4iAFEuzww==} engines: {node: ^20.19.0 || >=22.12.0} - '@jesscss/plugin-less-compat@2.0.0-alpha.31': - resolution: {integrity: sha512-1PK4mnAvvBGYUnKKdm8R9tx6TRhGnE8qrRbPf9Jl+6WEzJFq5bC47H/e5zTA+gbe81LlqzREdmbpZCn3wRibug==} + '@jesscss/plugin-less-compat@2.0.0-alpha.32': + resolution: {integrity: sha512-Q82V2wNCFW2SRz52WpH2jYDUulADK54tf0aHqypaPmf548lLfxO4N1Lxp0fvBmwZPFCpP55kDHn3RqA46K8Oow==} engines: {node: ^20.19.0 || >=22.12.0} - '@jesscss/plugin-less@2.0.0-alpha.31': - resolution: {integrity: sha512-V+mDqDQQCpISweIFUaQHFZX7i4IrQnCARlimweFkipPfujTEKk2GRVwcE3BbCHSRh3qY0pezdNFfhF8iShZd8A==} + '@jesscss/plugin-less@2.0.0-alpha.32': + resolution: {integrity: sha512-ms3kWXIysXUnhpdsxj34CP17Gk75Yn3mG4xf2Hb9WlkLKCEZvUzbbD/+BtJafXTzZofEF4UQ9LTTrhjVVqb0PQ==} engines: {node: ^20.19.0 || >=22.12.0} - '@jesscss/plugin-node-modules@2.0.0-alpha.31': - resolution: {integrity: sha512-U7h2ULJYNJMmzglYBcISbbFYZIeSGfyRNBWzXGk/Vm2hMBCC5egcJuqhGpSh5gaqt+27ZJhx8DaMiZMULko20g==} + '@jesscss/plugin-node-modules@2.0.0-alpha.32': + resolution: {integrity: sha512-j5Lt9u2Kcpwc3Dm8KamZARg53h1j9Eb0PcfeuBwrrovAautZn/dO9PeJVlE6AHE9/bfXQPS15jBf6tHxMSQhPg==} engines: {node: ^20.19.0 || >=22.12.0} - '@jesscss/style-resolver@2.0.0-alpha.31': - resolution: {integrity: sha512-UIKNvq4zdRUHn3/FnoF0y05T+1qU5wHeEvK7hL4gJC7clfs2UphyQyADK58d6BxMWS2l54xekCPpbD1tviFHPQ==} + '@jesscss/style-resolver@2.0.0-alpha.32': + resolution: {integrity: sha512-Em41ixTZhVO5k5AoNm7tw8OLe7vredpEN9I3imO0mimmVl+WpB7McgOt+kkpAhxreIef5ZYszZ7eOtHkAsbU4A==} engines: {node: ^20.19.0 || >=22.12.0} '@jest/diff-sequences@30.0.1': @@ -2555,8 +2555,8 @@ packages: resolution: {integrity: sha512-3YHlOa/JgH6Mnpr05jP9eDG254US9ek25LyIxZlDItp2iJtwyaXQb57lBYLdT3MowkUFYEV2XXNAYIPlESvJlA==} engines: {node: '>= 0.10'} - parseman@0.55.2: - resolution: {integrity: sha512-FmRj2BmiK08Ey6i4tK8XJPV7JARytnnxLnuozCeyPUVtSgWQ/qolx3zUNXpmjTY5Qz5WKMS/kzc8ui7tYzVDGQ==} + parseman@0.61.3: + resolution: {integrity: sha512-G+jg8bOQ8InHG6IYdEJfLaUsjYIh4mHeB717MM4u0l7WHNoLJb8q0W59poJyKr7K+unmhretSwCiejnX5vR6mg==} engines: {node: ^20.19.0 || >=22.13.0} hasBin: true @@ -3044,8 +3044,8 @@ packages: resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} engines: {node: '>=8'} - styles-config@2.0.0-alpha.31: - resolution: {integrity: sha512-SI+wqsVGZlTYlp4cNrYf7ByWp83inRTvw2eICq8dL7Db7+Q0EZLSS4gWqLCWSU0JPDhCCah8MwF98yCCpWYQQQ==} + styles-config@2.0.0-alpha.32: + resolution: {integrity: sha512-AW/D1+3ckP8OQ3XoE2yCcVUfG62HvZUdHOMsZeJupXlvHxoMBjo2QZwzl7Ik4F43zn4tvsO0EBOwWavBcoLBkw==} engines: {node: ^20.19.0 || >=22.12.0} superstruct@1.0.3: @@ -3559,76 +3559,75 @@ snapshots: '@istanbuljs/schema@0.1.6': {} - '@jesscss/awaitable-pipe@2.0.0-alpha.31': {} + '@jesscss/awaitable-pipe@2.0.0-alpha.32': {} - '@jesscss/compiler@2.0.0-alpha.31(typescript@5.9.3)': + '@jesscss/compiler@2.0.0-alpha.32(typescript@5.9.3)': dependencies: - '@jesscss/core': 2.0.0-alpha.31 + '@jesscss/core': 2.0.0-alpha.32 linecraft: 0.2.8 - lodash-es: 4.18.1 - styles-config: 2.0.0-alpha.31(typescript@5.9.3) + styles-config: 2.0.0-alpha.32(typescript@5.9.3) transitivePeerDependencies: - typescript - '@jesscss/core@2.0.0-alpha.31': + '@jesscss/core@2.0.0-alpha.32': dependencies: - '@jesscss/awaitable-pipe': 2.0.0-alpha.31 + '@jesscss/awaitable-pipe': 2.0.0-alpha.32 '@jridgewell/gen-mapping': 0.3.13 '@ungap/set-methods': 0.1.1 big.js: 7.0.1 chalk: 4.1.2 color-name: 2.0.2 - '@jesscss/css-parser@2.0.0-alpha.31(@jesscss/core@2.0.0-alpha.31)': + '@jesscss/css-parser@2.0.0-alpha.32(@jesscss/core@2.0.0-alpha.32)': dependencies: - '@jesscss/core': 2.0.0-alpha.31 - '@jesscss/parser-shared': 2.0.0-alpha.31 - parseman: 0.55.2 + '@jesscss/core': 2.0.0-alpha.32 + '@jesscss/parser-shared': 2.0.0-alpha.32 + parseman: 0.61.3 - '@jesscss/fns@2.0.0-alpha.31': + '@jesscss/fns@2.0.0-alpha.32': dependencies: - '@jesscss/awaitable-pipe': 2.0.0-alpha.31 - '@jesscss/core': 2.0.0-alpha.31 + '@jesscss/awaitable-pipe': 2.0.0-alpha.32 + '@jesscss/core': 2.0.0-alpha.32 big.js: 7.0.1 color-name: 2.0.2 lodash-es: 4.18.1 superstruct: 1.0.3 - '@jesscss/less-parser@2.0.0-alpha.31(@jesscss/core@2.0.0-alpha.31)': + '@jesscss/less-parser@2.0.0-alpha.32(@jesscss/core@2.0.0-alpha.32)': dependencies: - '@jesscss/core': 2.0.0-alpha.31 - '@jesscss/css-parser': 2.0.0-alpha.31(@jesscss/core@2.0.0-alpha.31) - '@jesscss/parser-shared': 2.0.0-alpha.31 - parseman: 0.55.2 + '@jesscss/core': 2.0.0-alpha.32 + '@jesscss/css-parser': 2.0.0-alpha.32(@jesscss/core@2.0.0-alpha.32) + '@jesscss/parser-shared': 2.0.0-alpha.32 + parseman: 0.61.3 - '@jesscss/parser-shared@2.0.0-alpha.31': + '@jesscss/parser-shared@2.0.0-alpha.32': dependencies: - parseman: 0.55.2 + parseman: 0.61.3 - '@jesscss/plugin-less-compat@2.0.0-alpha.31': + '@jesscss/plugin-less-compat@2.0.0-alpha.32': dependencies: - '@jesscss/awaitable-pipe': 2.0.0-alpha.31 - '@jesscss/core': 2.0.0-alpha.31 - '@jesscss/less-parser': 2.0.0-alpha.31(@jesscss/core@2.0.0-alpha.31) - '@jesscss/plugin-node-modules': 2.0.0-alpha.31 + '@jesscss/awaitable-pipe': 2.0.0-alpha.32 + '@jesscss/core': 2.0.0-alpha.32 + '@jesscss/less-parser': 2.0.0-alpha.32(@jesscss/core@2.0.0-alpha.32) + '@jesscss/plugin-node-modules': 2.0.0-alpha.32 - '@jesscss/plugin-less@2.0.0-alpha.31(typescript@5.9.3)': + '@jesscss/plugin-less@2.0.0-alpha.32(typescript@5.9.3)': dependencies: - '@jesscss/core': 2.0.0-alpha.31 - '@jesscss/fns': 2.0.0-alpha.31 - '@jesscss/less-parser': 2.0.0-alpha.31(@jesscss/core@2.0.0-alpha.31) - '@jesscss/plugin-less-compat': 2.0.0-alpha.31 - '@jesscss/style-resolver': 2.0.0-alpha.31 - styles-config: 2.0.0-alpha.31(typescript@5.9.3) + '@jesscss/core': 2.0.0-alpha.32 + '@jesscss/fns': 2.0.0-alpha.32 + '@jesscss/less-parser': 2.0.0-alpha.32(@jesscss/core@2.0.0-alpha.32) + '@jesscss/plugin-less-compat': 2.0.0-alpha.32 + '@jesscss/style-resolver': 2.0.0-alpha.32 + styles-config: 2.0.0-alpha.32(typescript@5.9.3) transitivePeerDependencies: - typescript - '@jesscss/plugin-node-modules@2.0.0-alpha.31': + '@jesscss/plugin-node-modules@2.0.0-alpha.32': dependencies: - '@jesscss/core': 2.0.0-alpha.31 - '@jesscss/fns': 2.0.0-alpha.31 + '@jesscss/core': 2.0.0-alpha.32 + '@jesscss/fns': 2.0.0-alpha.32 - '@jesscss/style-resolver@2.0.0-alpha.31': {} + '@jesscss/style-resolver@2.0.0-alpha.32': {} '@jest/diff-sequences@30.0.1': {} @@ -5824,7 +5823,7 @@ snapshots: parse-node-version@1.0.1: {} - parseman@0.55.2: + parseman@0.61.3: dependencies: linecraft: 0.2.6 magic-string: 0.30.21 @@ -6330,9 +6329,9 @@ snapshots: strip-json-comments@3.1.1: {} - styles-config@2.0.0-alpha.31(typescript@5.9.3): + styles-config@2.0.0-alpha.32(typescript@5.9.3): dependencies: - '@jesscss/core': 2.0.0-alpha.31 + '@jesscss/core': 2.0.0-alpha.32 cosmiconfig: 9.0.2(typescript@5.9.3) picomatch: 4.0.5 transitivePeerDependencies: diff --git a/scripts/verify-alpha-packed-consumer.mjs b/scripts/verify-alpha-packed-consumer.mjs index 45a439f0b9..cff2b6dcc3 100644 --- a/scripts/verify-alpha-packed-consumer.mjs +++ b/scripts/verify-alpha-packed-consumer.mjs @@ -351,6 +351,46 @@ console.log('packed lessc stdin, file/import, and malformed-input paths passed') return checkPath; } +/** + * `@plugin` through `less.render()`, `require('less').render()` and `lessc`, in a + * consumer that installed the optional peer. The render moves whole into the + * plugin's Deno sandbox, where the compiler is made again from + * `LessCompiler.moduleIdentity`, so this fails with `plugin/load-failed` if the + * identity goes away. Nothing here skips: a missing Deno fails the render too. + */ +function writeConsumerPluginCheck(consumerDir) { + const checkPath = path.join(consumerDir, 'verify-plugin.mjs'); + writeFileSync(checkPath, ` +import assert from 'node:assert/strict'; +import { spawnSync } from 'node:child_process'; +import { mkdirSync, writeFileSync } from 'node:fs'; +import { createRequire } from 'node:module'; +import path from 'node:path'; +import less from 'less'; + +const fixture = path.join(process.cwd(), 'plugin-fixture'); +mkdirSync(fixture, { recursive: true }); +writeFileSync(path.join(fixture, 'answer.js'), "functions.add('plugin-answer', () => new tree.Anonymous('42'));\\n"); +const source = '@plugin "./answer.js";\\n.a { b: plugin-answer(); }\\n'; +const entry = path.join(fixture, 'entry.less'); +writeFileSync(entry, source); + +const rendered = await less.render(source, { filename: entry }); +assert.match(rendered.css, /\\.a \\{\\s*b: 42;\\s*\\}/u, 'less.render() did not run the @plugin function'); + +const required = createRequire(import.meta.url)('less'); +const requiredRender = await required.render(source, { filename: entry }); +assert.match(requiredRender.css, /\\.a \\{\\s*b: 42;\\s*\\}/u, "require('less').render() did not run the @plugin function"); + +const lessc = path.join(process.cwd(), 'node_modules', '.bin', process.platform === 'win32' ? 'lessc.cmd' : 'lessc'); +const cli = spawnSync(lessc, ['entry.less'], { cwd: fixture, encoding: 'utf8', shell: process.platform === 'win32' }); +assert.equal(cli.status, 0, cli.stderr); +assert.match(cli.stdout, /\\.a \\{\\s*b: 42;\\s*\\}/u, 'lessc did not run the @plugin function'); +console.log('packed @plugin through less.render() and lessc passed'); +`.trimStart()); + return checkPath; +} + function main() { const tempRoot = mkdtempSync(path.join(os.tmpdir(), 'less-alpha-packed-consumer-')); const packDir = path.join(tempRoot, 'packs'); @@ -378,6 +418,11 @@ function main() { ); assertConsumerRegistryPackages(consumerDir, [lessRoot], lessJessDependencies); run(process.execPath, [writeConsumerChecks(consumerDir)], consumerDir); + run('npm', ['install', '--ignore-scripts', '--no-audit', '--no-fund', '--omit=dev', `${optionalScriptPluginPeer}@${expectedJessVersion}`], consumerDir); + // The `deno` package's own install script, run directly: `npm rebuild deno` + // exits 0 and leaves no binary on npm 12. + run(process.execPath, ['install.cjs'], path.join(consumerDir, 'node_modules', 'deno')); + run(process.execPath, [writeConsumerPluginCheck(consumerDir)], consumerDir); console.log(`\nPacked Less ${less.version} consumer proof passed with Jess ${expectedJessVersion}.`); } finally { if (keep) {