Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"runtimeArgs": [
"--enable-source-maps",
"--test",
"lib/umd/test/**/*.test.js"
"lib/esm/test/**/*.test.js"
],
"cwd": "${workspaceRoot}",
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/lib/umd/**"
"${workspaceRoot}/lib/esm/**"
],
"skipFiles": [
"<node_internals>/**"
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
7.0.0-next.1 / 2026-03-04
=========================
* BREAKING: package is now ESM-only (`"type": "module"`) and no longer publishes `lib/umd` output
* BREAKING: package entrypoints now use `exports` and `types` from `lib/esm`
* BREAKING: runtime and test output moved to `lib/esm` and source imports use explicit `.js` extensions for NodeNext compatibility
* Build scripts in `build/` are now ESM
* `update-jsbeautify` now writes the ESM formatter source directly to `src/beautify/beautify-css.js`

6.3.0 / 2022-06-24
================
* new optional API `fileSystemProvider.getContent`
Expand Down
23 changes: 0 additions & 23 deletions build/copy-jsbeautify.js

This file was deleted.

16 changes: 10 additions & 6 deletions build/generateData.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

const fs = require('fs')
const path = require('path')
const os = require('os')
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { createRequire } from 'node:module';
import { fileURLToPath } from 'node:url';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const require = createRequire(import.meta.url);
const customData = require('@vscode/web-custom-data/data/browsers.css-data.json');

function toJavaScript(obj) {
Expand All @@ -21,13 +25,13 @@ const output = [
' *--------------------------------------------------------------------------------------------*/',
'// file generated from @vscode/web-custom-data NPM package',
'',
`import { ${DATA_TYPE} } from '../cssLanguageTypes';`,
`import { ${DATA_TYPE} } from '../cssLanguageTypes.js';`,
'',
`export const cssData : ${DATA_TYPE} = ` + toJavaScript(customData) + ';'
];

var outputPath = path.resolve(__dirname, '../src/data/webCustomData.ts');
const outputPath = path.resolve(__dirname, '../src/data/webCustomData.ts');
console.log('Writing to: ' + outputPath);
var content = output.join(os.EOL);
const content = output.join(os.EOL);
fs.writeFileSync(outputPath, content);
console.log('Done');
9 changes: 6 additions & 3 deletions build/remove-sourcemap-refs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

const fs = require('fs');
const path = require('path');
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

function deleteRefs(dir) {
const files = fs.readdirSync(dir);
Expand All @@ -27,6 +30,6 @@ function deleteRefs(dir) {
}
}

let location = path.join(__dirname, '..', 'lib');
const location = path.join(__dirname, '..', 'lib');
console.log('process ' + location);
deleteRefs(location);
132 changes: 64 additions & 68 deletions build/update-jsbeautify.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,86 +3,82 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

'use strict';
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

var path = require('path');
var fs = require('fs');
const __dirname = path.dirname(fileURLToPath(import.meta.url));

function getVersion(moduleName) {
var packageJSONPath = path.join(__dirname, '..', 'node_modules', moduleName, 'package.json');
return readFile(packageJSONPath).then(function (content) {
try {
return JSON.parse(content).version;
} catch (e) {
return Promise.resolve(null);
}
});
async function getVersion(moduleName) {
const packageJSONPath = path.join(__dirname, '..', 'node_modules', moduleName, 'package.json');
const content = await readFile(packageJSONPath);
try {
return JSON.parse(content).version;
} catch {
return null;
}
}

function readFile(path) {
return new Promise((s, e) => {
fs.readFile(path, (err, res) => {
function readFile(filePath) {
return new Promise((resolve, reject) => {
fs.readFile(filePath, (err, res) => {
if (err) {
e(err);
reject(err);
} else {
s(res.toString());
resolve(res.toString());
}
});
});

}

function update(moduleName, repoPath, dest, addHeader, patch) {
var contentPath = path.join(__dirname, '..', 'node_modules', moduleName, repoPath);
async function update(moduleName, repoPath, dest, addHeader, patch) {
const contentPath = path.join(__dirname, '..', 'node_modules', moduleName, repoPath);
console.log('Reading from ' + contentPath);
return readFile(contentPath).then(function (content) {
return getVersion(moduleName).then(function (version) {
let header = '';
if (addHeader) {
header = '// copied from js-beautify/' + repoPath + '\n';
if (version) {
header += '// version: ' + version + '\n';
}
}
try {
if (patch) {
content = patch(content);
}
fs.writeFileSync(dest, header + content);
if (version) {
console.log('Updated ' + path.basename(dest) + ' (' + version + ')');
} else {
console.log('Updated ' + path.basename(dest));
}
} catch (e) {
console.error(e);
try {
let content = await readFile(contentPath);
const version = await getVersion(moduleName);
let header = '';
if (addHeader) {
header = '// copied from js-beautify/' + repoPath + '\n';
if (version) {
header += '// version: ' + version + '\n';
}
});

}, console.error);
}
if (patch) {
content = patch(content);
}
fs.writeFileSync(dest, header + content);
if (version) {
console.log('Updated ' + path.basename(dest) + ' (' + version + ')');
} else {
console.log('Updated ' + path.basename(dest));
}
} catch (e) {
console.error(e);
}
}

update('js-beautify', 'js/lib/beautify-css.js', './src/beautify/beautify-css.js', true);
update('js-beautify', 'LICENSE', './src/beautify/beautify-license');

// ESM version
update('js-beautify', 'js/lib/beautify-css.js', './src/beautify/esm/beautify-css.js', true, function (contents) {
let topLevelFunction = '(function() {';
let outputVar = 'var legacy_beautify_css';
let footer = 'var css_beautify = legacy_beautify_css;';
let index1 = contents.indexOf(topLevelFunction);
let index2 = contents.indexOf(outputVar, index1);
let index3 = contents.indexOf(footer, index2);
if (index1 === -1) {
throw new Error(`Problem patching beautify.css for ESM: '${topLevelFunction}' not found.`);
}
if (index2 === -1) {
throw new Error(`Problem patching beautify.css for ESM: '${outputVar}' not found after '${topLevelFunction}'.`);
}
if (index3 === -1) {
throw new Error(`Problem patching beautify.css for ESM: '${footer}' not found after '${outputVar}'.`);
}
return contents.substring(0, index1) +
contents.substring(index2, index3) +
`\nexport var css_beautify = legacy_beautify_css;`;
});
await Promise.all([
update('js-beautify', 'LICENSE', './src/beautify/beautify-license'),
// Write the ESM-compatible variant directly to the main source path.
update('js-beautify', 'js/lib/beautify-css.js', './src/beautify/beautify-css.js', true, (contents) => {
const topLevelFunction = '(function() {';
const outputVar = 'var legacy_beautify_css';
const footer = 'var css_beautify = legacy_beautify_css;';
const index1 = contents.indexOf(topLevelFunction);
const index2 = contents.indexOf(outputVar, index1);
const index3 = contents.indexOf(footer, index2);
if (index1 === -1) {
throw new Error(`Problem patching beautify.css for ESM: '${topLevelFunction}' not found.`);
}
if (index2 === -1) {
throw new Error(`Problem patching beautify.css for ESM: '${outputVar}' not found after '${topLevelFunction}'.`);
}
if (index3 === -1) {
throw new Error(`Problem patching beautify.css for ESM: '${footer}' not found after '${outputVar}'.`);
}
return contents.substring(0, index1) +
contents.substring(index2, index3) +
'\nexport var css_beautify = legacy_beautify_css;';
})
]);
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 14 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{
"name": "vscode-css-languageservice",
"version": "6.3.10",
"version": "7.0.0-next.1",
"description": "Language service for CSS, LESS and SCSS",
"main": "./lib/umd/cssLanguageService.js",
"typings": "./lib/umd/cssLanguageService",
"module": "./lib/esm/cssLanguageService.js",
"type": "module",
"exports": {
".": {
"types": "./lib/esm/cssLanguageService.d.ts",
"import": "./lib/esm/cssLanguageService.js"
}
},
"types": "./lib/esm/cssLanguageService.d.ts",
"author": "Microsoft Corporation",
"repository": {
"type": "git",
Expand All @@ -31,19 +36,17 @@
"vscode-uri": "^3.1.0"
},
"scripts": {
"prepack": "npm run clean && npm run compile-esm && npm run test && npm run remove-sourcemap-refs",
"compile": "tsc -p ./src && npm run copy-jsbeautify && npm run lint",
"compile-esm": "tsc -p ./src/tsconfig.esm.json",
"prepack": "npm run clean && npm run compile && npm run test && npm run remove-sourcemap-refs",
"compile": "tsc -p ./src && npm run lint",
"clean": "rimraf lib",
"remove-sourcemap-refs": "node ./build/remove-sourcemap-refs.js",
"watch": "npm run copy-jsbeautify && tsc -w -p ./src",
"watch": "tsc -w -p ./src",
"test": "npm run compile && npm run node-test",
"node-test": "node --enable-source-maps --test lib/umd/test/**/*.test.js",
"coverage": "npm run compile && npx nyc --reporter=html --reporter=text node --test lib/umd/test/**/*.test.js",
"node-test": "node --enable-source-maps --test lib/esm/test/**/*.test.js",
"coverage": "npm run compile && npx nyc --reporter=html --reporter=text node --test lib/esm/test/**/*.test.js",
"lint": "eslint src/**/*.ts",
"update-data": "npm install @vscode/web-custom-data -D && node ./build/generateData.js",
"install-types-next": "npm install vscode-languageserver-types@next -f -S && npm install vscode-languageserver-textdocument@next -f -S",
"copy-jsbeautify": "node ./build/copy-jsbeautify.js",
"update-jsbeautify": "npm install js-beautify && node ./build/update-jsbeautify.js",
"update-jsbeautify-next": "npm install js-beautify@next && node ./build/update-jsbeautify.js"
}
Expand Down
25 changes: 1 addition & 24 deletions src/beautify/beautify-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@
// http://www.w3.org/TR/CSS21/syndata.html#tokenization
// http://www.w3.org/TR/css3-syntax/

(function() {

/* GENERATED_BUILD_OUTPUT */
var legacy_beautify_css;
/******/ (function() { // webpackBootstrap
/******/ "use strict";
Expand Down Expand Up @@ -1671,25 +1668,5 @@ module.exports.Options = Options;
/******/
/******/ })()
;
var css_beautify = legacy_beautify_css;
/* Footer */
if (typeof define === "function" && define.amd) {
// Add support for AMD ( https://github.com/amdjs/amdjs-api/wiki/AMD#defineamd-property- )
define([], function() {
return {
css_beautify: css_beautify
};
});
} else if (typeof exports !== "undefined") {
// Add support for CommonJS. Just put this file somewhere on your require.paths
// and you will be able to `var html_beautify = require("beautify").html_beautify`.
exports.css_beautify = css_beautify;
} else if (typeof window !== "undefined") {
// If we're running a web page and don't have either of the above, add our one global
window.css_beautify = css_beautify;
} else if (typeof global !== "undefined") {
// If we don't even have window, try global.
global.css_beautify = css_beautify;
}

}());
export var css_beautify = legacy_beautify_css;
Loading