vite 3.0.8 → 3.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +46 -116
- package/dist/client/client.mjs +9 -24
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-74663fff.js → dep-3ffe6dd0.js} +24171 -23791
- package/dist/node/chunks/dep-4069c338.js +8079 -0
- package/dist/node/chunks/{dep-399ffe4b.js → dep-6cde6b83.js} +142 -154
- package/dist/node/cli.js +7 -6
- package/dist/node/constants.js +1 -1
- package/dist/node/index.d.ts +44 -30
- package/dist/node/index.js +3 -2
- package/dist/node-cjs/publicUtils.cjs +7 -2
- package/package.json +12 -12
- package/src/client/client.ts +28 -40
- package/types/chokidar.d.ts +1 -1
- package/types/http-proxy.d.ts +1 -1
- package/types/importGlob.d.ts +15 -5
- package/dist/node/chunks/dep-aabb0c58.js +0 -8816
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import require$$0$1 from 'postcss';
|
|
2
|
-
import { z as commonjsGlobal } from './dep-
|
|
2
|
+
import { z as commonjsGlobal } from './dep-3ffe6dd0.js';
|
|
3
3
|
import require$$0 from 'path';
|
|
4
4
|
import require$$5 from 'crypto';
|
|
5
5
|
import require$$0__default from 'fs';
|
|
@@ -1388,19 +1388,21 @@ Object.defineProperty(unquote$1, "__esModule", {
|
|
|
1388
1388
|
});
|
|
1389
1389
|
unquote$1.default = unquote;
|
|
1390
1390
|
// copied from https://github.com/lakenen/node-unquote
|
|
1391
|
-
|
|
1392
1391
|
var reg = /['"]/;
|
|
1393
1392
|
|
|
1394
1393
|
function unquote(str) {
|
|
1395
1394
|
if (!str) {
|
|
1396
1395
|
return "";
|
|
1397
1396
|
}
|
|
1397
|
+
|
|
1398
1398
|
if (reg.test(str.charAt(0))) {
|
|
1399
1399
|
str = str.substr(1);
|
|
1400
1400
|
}
|
|
1401
|
+
|
|
1401
1402
|
if (reg.test(str.charAt(str.length - 1))) {
|
|
1402
1403
|
str = str.substr(0, str.length - 1);
|
|
1403
1404
|
}
|
|
1405
|
+
|
|
1404
1406
|
return str;
|
|
1405
1407
|
}
|
|
1406
1408
|
|
|
@@ -1438,16 +1440,15 @@ lib.default = function (css, translations) {
|
|
|
1438
1440
|
Object.defineProperty(parser$1, "__esModule", {
|
|
1439
1441
|
value: true
|
|
1440
1442
|
});
|
|
1443
|
+
parser$1.default = void 0;
|
|
1441
1444
|
|
|
1442
|
-
var _icssReplaceSymbols = lib;
|
|
1443
|
-
|
|
1444
|
-
var _icssReplaceSymbols2 = _interopRequireDefault$6(_icssReplaceSymbols);
|
|
1445
|
+
var _icssReplaceSymbols = _interopRequireDefault$6(lib);
|
|
1445
1446
|
|
|
1446
1447
|
function _interopRequireDefault$6(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1447
1448
|
|
|
1448
1449
|
// Copied from https://github.com/css-modules/css-modules-loader-core
|
|
1449
|
-
|
|
1450
1450
|
const importRegexp = /^:import\((.+)\)$/;
|
|
1451
|
+
|
|
1451
1452
|
class Parser {
|
|
1452
1453
|
constructor(pathFetcher, trace) {
|
|
1453
1454
|
this.pathFetcher = pathFetcher;
|
|
@@ -1461,9 +1462,11 @@ class Parser {
|
|
|
1461
1462
|
const parser = this;
|
|
1462
1463
|
return {
|
|
1463
1464
|
postcssPlugin: "css-modules-parser",
|
|
1465
|
+
|
|
1464
1466
|
OnceExit(css) {
|
|
1465
1467
|
return Promise.all(parser.fetchAllImports(css)).then(() => parser.linkImportedSymbols(css)).then(() => parser.extractExports(css));
|
|
1466
1468
|
}
|
|
1469
|
+
|
|
1467
1470
|
};
|
|
1468
1471
|
}
|
|
1469
1472
|
|
|
@@ -1478,7 +1481,7 @@ class Parser {
|
|
|
1478
1481
|
}
|
|
1479
1482
|
|
|
1480
1483
|
linkImportedSymbols(css) {
|
|
1481
|
-
(0,
|
|
1484
|
+
(0, _icssReplaceSymbols.default)(css, this.translations);
|
|
1482
1485
|
}
|
|
1483
1486
|
|
|
1484
1487
|
extractExports(css) {
|
|
@@ -1511,7 +1514,9 @@ class Parser {
|
|
|
1511
1514
|
importNode.remove();
|
|
1512
1515
|
}, err => console.log(err));
|
|
1513
1516
|
}
|
|
1517
|
+
|
|
1514
1518
|
}
|
|
1519
|
+
|
|
1515
1520
|
parser$1.default = Parser;
|
|
1516
1521
|
|
|
1517
1522
|
var loader = {};
|
|
@@ -1519,51 +1524,45 @@ var loader = {};
|
|
|
1519
1524
|
Object.defineProperty(loader, "__esModule", {
|
|
1520
1525
|
value: true
|
|
1521
1526
|
});
|
|
1527
|
+
loader.default = void 0;
|
|
1522
1528
|
|
|
1523
|
-
var _postcss$1 = require$$0$1;
|
|
1524
|
-
|
|
1525
|
-
var _postcss2$1 = _interopRequireDefault$5(_postcss$1);
|
|
1526
|
-
|
|
1527
|
-
var _fs$1 = require$$0__default;
|
|
1528
|
-
|
|
1529
|
-
var _fs2 = _interopRequireDefault$5(_fs$1);
|
|
1530
|
-
|
|
1531
|
-
var _path = require$$0;
|
|
1529
|
+
var _postcss$1 = _interopRequireDefault$5(require$$0$1);
|
|
1532
1530
|
|
|
1533
|
-
var
|
|
1531
|
+
var _fs$1 = _interopRequireDefault$5(require$$0__default);
|
|
1534
1532
|
|
|
1535
|
-
var
|
|
1533
|
+
var _path = _interopRequireDefault$5(require$$0);
|
|
1536
1534
|
|
|
1537
|
-
var
|
|
1535
|
+
var _parser$1 = _interopRequireDefault$5(parser$1);
|
|
1538
1536
|
|
|
1539
1537
|
function _interopRequireDefault$5(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1540
1538
|
|
|
1541
1539
|
// Copied from https://github.com/css-modules/css-modules-loader-core
|
|
1542
|
-
|
|
1543
1540
|
class Core {
|
|
1544
1541
|
constructor(plugins) {
|
|
1545
1542
|
this.plugins = plugins || Core.defaultPlugins;
|
|
1546
1543
|
}
|
|
1547
1544
|
|
|
1548
1545
|
load(sourceString, sourcePath, trace, pathFetcher) {
|
|
1549
|
-
let parser = new
|
|
1550
|
-
|
|
1551
|
-
|
|
1546
|
+
let parser = new _parser$1.default(pathFetcher, trace);
|
|
1547
|
+
return (0, _postcss$1.default)(this.plugins.concat([parser.plugin()])).process(sourceString, {
|
|
1548
|
+
from: sourcePath
|
|
1549
|
+
}).then(result => {
|
|
1552
1550
|
return {
|
|
1553
1551
|
injectableSource: result.css,
|
|
1554
1552
|
exportTokens: parser.exportTokens
|
|
1555
1553
|
};
|
|
1556
1554
|
});
|
|
1557
1555
|
}
|
|
1558
|
-
}
|
|
1559
1556
|
|
|
1560
|
-
// Sorts dependencies in the following way:
|
|
1557
|
+
} // Sorts dependencies in the following way:
|
|
1561
1558
|
// AAA comes before AA and A
|
|
1562
1559
|
// AB comes after AA and before A
|
|
1563
1560
|
// All Bs come after all As
|
|
1564
1561
|
// This ensures that the files are always returned in the following order:
|
|
1565
1562
|
// - In the order they were required, except
|
|
1566
1563
|
// - After all their dependencies
|
|
1564
|
+
|
|
1565
|
+
|
|
1567
1566
|
const traceKeySorter = (a, b) => {
|
|
1568
1567
|
if (a.length < b.length) {
|
|
1569
1568
|
return a < b.substring(0, a.length) ? -1 : 1;
|
|
@@ -1576,6 +1575,16 @@ const traceKeySorter = (a, b) => {
|
|
|
1576
1575
|
|
|
1577
1576
|
class FileSystemLoader {
|
|
1578
1577
|
constructor(root, plugins) {
|
|
1578
|
+
if (root === '/' && process.platform === "win32") {
|
|
1579
|
+
const cwdDrive = process.cwd().slice(0, 3);
|
|
1580
|
+
|
|
1581
|
+
if (!/^[A-Z]:\\$/.test(cwdDrive)) {
|
|
1582
|
+
throw new Error(`Failed to obtain root from "${process.cwd()}".`);
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
root = cwdDrive;
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1579
1588
|
this.root = root;
|
|
1580
1589
|
this.sources = {};
|
|
1581
1590
|
this.traces = {};
|
|
@@ -1587,28 +1596,32 @@ class FileSystemLoader {
|
|
|
1587
1596
|
fetch(_newPath, relativeTo, _trace) {
|
|
1588
1597
|
let newPath = _newPath.replace(/^["']|["']$/g, ""),
|
|
1589
1598
|
trace = _trace || String.fromCharCode(this.importNr++);
|
|
1599
|
+
|
|
1590
1600
|
return new Promise((resolve, reject) => {
|
|
1591
|
-
let relativeDir =
|
|
1592
|
-
rootRelativePath =
|
|
1593
|
-
fileRelativePath =
|
|
1601
|
+
let relativeDir = _path.default.dirname(relativeTo),
|
|
1602
|
+
rootRelativePath = _path.default.resolve(relativeDir, newPath),
|
|
1603
|
+
fileRelativePath = _path.default.resolve(_path.default.resolve(this.root, relativeDir), newPath); // if the path is not relative or absolute, try to resolve it in node_modules
|
|
1604
|
+
|
|
1594
1605
|
|
|
1595
|
-
|
|
1596
|
-
if (newPath[0] !== "." && newPath[0] !== "/") {
|
|
1606
|
+
if (newPath[0] !== "." && !_path.default.isAbsolute(newPath)) {
|
|
1597
1607
|
try {
|
|
1598
1608
|
fileRelativePath = require.resolve(newPath);
|
|
1599
|
-
} catch (e) {
|
|
1600
|
-
// noop
|
|
1609
|
+
} catch (e) {// noop
|
|
1601
1610
|
}
|
|
1602
1611
|
}
|
|
1603
1612
|
|
|
1604
1613
|
const tokens = this.tokensByFile[fileRelativePath];
|
|
1614
|
+
|
|
1605
1615
|
if (tokens) {
|
|
1606
1616
|
return resolve(tokens);
|
|
1607
1617
|
}
|
|
1608
1618
|
|
|
1609
|
-
|
|
1619
|
+
_fs$1.default.readFile(fileRelativePath, "utf-8", (err, source) => {
|
|
1610
1620
|
if (err) reject(err);
|
|
1611
|
-
this.core.load(source, rootRelativePath, trace, this.fetch.bind(this)).then(({
|
|
1621
|
+
this.core.load(source, rootRelativePath, trace, this.fetch.bind(this)).then(({
|
|
1622
|
+
injectableSource,
|
|
1623
|
+
exportTokens
|
|
1624
|
+
}) => {
|
|
1612
1625
|
this.sources[fileRelativePath] = injectableSource;
|
|
1613
1626
|
this.traces[trace] = fileRelativePath;
|
|
1614
1627
|
this.tokensByFile[fileRelativePath] = exportTokens;
|
|
@@ -1622,18 +1635,20 @@ class FileSystemLoader {
|
|
|
1622
1635
|
const traces = this.traces;
|
|
1623
1636
|
const sources = this.sources;
|
|
1624
1637
|
let written = new Set();
|
|
1625
|
-
|
|
1626
1638
|
return Object.keys(traces).sort(traceKeySorter).map(key => {
|
|
1627
1639
|
const filename = traces[key];
|
|
1640
|
+
|
|
1628
1641
|
if (written.has(filename)) {
|
|
1629
1642
|
return null;
|
|
1630
1643
|
}
|
|
1631
|
-
written.add(filename);
|
|
1632
1644
|
|
|
1645
|
+
written.add(filename);
|
|
1633
1646
|
return sources[filename];
|
|
1634
1647
|
}).join("");
|
|
1635
1648
|
}
|
|
1649
|
+
|
|
1636
1650
|
}
|
|
1651
|
+
|
|
1637
1652
|
loader.default = FileSystemLoader;
|
|
1638
1653
|
|
|
1639
1654
|
var generateScopedName$1 = {};
|
|
@@ -1659,17 +1674,14 @@ Object.defineProperty(generateScopedName$1, "__esModule", {
|
|
|
1659
1674
|
});
|
|
1660
1675
|
generateScopedName$1.default = generateScopedName;
|
|
1661
1676
|
|
|
1662
|
-
var _stringHash = stringHash;
|
|
1663
|
-
|
|
1664
|
-
var _stringHash2 = _interopRequireDefault$4(_stringHash);
|
|
1677
|
+
var _stringHash = _interopRequireDefault$4(stringHash);
|
|
1665
1678
|
|
|
1666
1679
|
function _interopRequireDefault$4(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1667
1680
|
|
|
1668
1681
|
function generateScopedName(name, filename, css) {
|
|
1669
1682
|
const i = css.indexOf(`.${name}`);
|
|
1670
1683
|
const lineNumber = css.substr(0, i).split(/[\r\n]/).length;
|
|
1671
|
-
const hash = (0,
|
|
1672
|
-
|
|
1684
|
+
const hash = (0, _stringHash.default)(css).toString(36).substr(0, 5);
|
|
1673
1685
|
return `_${name}_${hash}_${lineNumber}`;
|
|
1674
1686
|
}
|
|
1675
1687
|
|
|
@@ -7309,45 +7321,43 @@ src.exports.postcss = true;
|
|
|
7309
7321
|
Object.defineProperty(behaviours$1, "__esModule", {
|
|
7310
7322
|
value: true
|
|
7311
7323
|
});
|
|
7312
|
-
behaviours$1.behaviours =
|
|
7324
|
+
behaviours$1.behaviours = void 0;
|
|
7313
7325
|
behaviours$1.getDefaultPlugins = getDefaultPlugins;
|
|
7314
7326
|
behaviours$1.isValidBehaviour = isValidBehaviour;
|
|
7315
7327
|
|
|
7316
|
-
var _postcssModulesLocalByDefault = src$4.exports;
|
|
7317
|
-
|
|
7318
|
-
var _postcssModulesLocalByDefault2 = _interopRequireDefault$1(_postcssModulesLocalByDefault);
|
|
7319
|
-
|
|
7320
|
-
var _postcssModulesExtractImports = src$2.exports;
|
|
7321
|
-
|
|
7322
|
-
var _postcssModulesExtractImports2 = _interopRequireDefault$1(_postcssModulesExtractImports);
|
|
7323
|
-
|
|
7324
|
-
var _postcssModulesScope = src$1;
|
|
7328
|
+
var _postcssModulesLocalByDefault = _interopRequireDefault$1(src$4.exports);
|
|
7325
7329
|
|
|
7326
|
-
var
|
|
7330
|
+
var _postcssModulesExtractImports = _interopRequireDefault$1(src$2.exports);
|
|
7327
7331
|
|
|
7328
|
-
var
|
|
7332
|
+
var _postcssModulesScope = _interopRequireDefault$1(src$1);
|
|
7329
7333
|
|
|
7330
|
-
var
|
|
7334
|
+
var _postcssModulesValues = _interopRequireDefault$1(src.exports);
|
|
7331
7335
|
|
|
7332
7336
|
function _interopRequireDefault$1(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7333
7337
|
|
|
7334
|
-
const behaviours =
|
|
7338
|
+
const behaviours = {
|
|
7335
7339
|
LOCAL: "local",
|
|
7336
7340
|
GLOBAL: "global"
|
|
7337
7341
|
};
|
|
7342
|
+
behaviours$1.behaviours = behaviours;
|
|
7338
7343
|
|
|
7339
7344
|
function getDefaultPlugins({
|
|
7340
7345
|
behaviour,
|
|
7341
7346
|
generateScopedName,
|
|
7342
7347
|
exportGlobals
|
|
7343
7348
|
}) {
|
|
7344
|
-
const scope = (0,
|
|
7345
|
-
|
|
7349
|
+
const scope = (0, _postcssModulesScope.default)({
|
|
7350
|
+
generateScopedName,
|
|
7351
|
+
exportGlobals
|
|
7352
|
+
});
|
|
7346
7353
|
const plugins = {
|
|
7347
|
-
[behaviours.LOCAL]: [
|
|
7348
|
-
|
|
7354
|
+
[behaviours.LOCAL]: [_postcssModulesValues.default, (0, _postcssModulesLocalByDefault.default)({
|
|
7355
|
+
mode: 'local'
|
|
7356
|
+
}), _postcssModulesExtractImports.default, scope],
|
|
7357
|
+
[behaviours.GLOBAL]: [_postcssModulesValues.default, (0, _postcssModulesLocalByDefault.default)({
|
|
7358
|
+
mode: 'global'
|
|
7359
|
+
}), _postcssModulesExtractImports.default, scope]
|
|
7349
7360
|
};
|
|
7350
|
-
|
|
7351
7361
|
return plugins[behaviour];
|
|
7352
7362
|
}
|
|
7353
7363
|
|
|
@@ -7355,44 +7365,26 @@ function isValidBehaviour(behaviour) {
|
|
|
7355
7365
|
return Object.keys(behaviours).map(key => behaviours[key]).indexOf(behaviour) > -1;
|
|
7356
7366
|
}
|
|
7357
7367
|
|
|
7358
|
-
var _postcss = require$$0$1;
|
|
7359
|
-
|
|
7360
|
-
var _postcss2 = _interopRequireDefault(_postcss);
|
|
7361
|
-
|
|
7362
|
-
var _lodash = lodash_camelcase;
|
|
7363
|
-
|
|
7364
|
-
var _lodash2 = _interopRequireDefault(_lodash);
|
|
7365
|
-
|
|
7366
|
-
var _genericNames = genericNames;
|
|
7367
|
-
|
|
7368
|
-
var _genericNames2 = _interopRequireDefault(_genericNames);
|
|
7368
|
+
var _postcss = _interopRequireDefault(require$$0$1);
|
|
7369
7369
|
|
|
7370
|
-
var
|
|
7370
|
+
var _lodash = _interopRequireDefault(lodash_camelcase);
|
|
7371
7371
|
|
|
7372
|
-
var
|
|
7372
|
+
var _genericNames = _interopRequireDefault(genericNames);
|
|
7373
7373
|
|
|
7374
|
-
var
|
|
7374
|
+
var _unquote = _interopRequireDefault(unquote$1);
|
|
7375
7375
|
|
|
7376
|
-
var
|
|
7376
|
+
var _parser = _interopRequireDefault(parser$1);
|
|
7377
7377
|
|
|
7378
|
-
var _loader = loader;
|
|
7378
|
+
var _loader = _interopRequireDefault(loader);
|
|
7379
7379
|
|
|
7380
|
-
var
|
|
7380
|
+
var _generateScopedName = _interopRequireDefault(generateScopedName$1);
|
|
7381
7381
|
|
|
7382
|
-
var
|
|
7383
|
-
|
|
7384
|
-
var _generateScopedName2 = _interopRequireDefault(_generateScopedName);
|
|
7385
|
-
|
|
7386
|
-
var _saveJSON = saveJSON$1;
|
|
7387
|
-
|
|
7388
|
-
var _saveJSON2 = _interopRequireDefault(_saveJSON);
|
|
7382
|
+
var _saveJSON = _interopRequireDefault(saveJSON$1);
|
|
7389
7383
|
|
|
7390
7384
|
var _behaviours = behaviours$1;
|
|
7391
7385
|
|
|
7392
7386
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7393
7387
|
|
|
7394
|
-
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
|
7395
|
-
|
|
7396
7388
|
const PLUGIN_NAME = "postcss-modules";
|
|
7397
7389
|
|
|
7398
7390
|
function getDefaultScopeBehaviour(opts) {
|
|
@@ -7404,10 +7396,9 @@ function getDefaultScopeBehaviour(opts) {
|
|
|
7404
7396
|
}
|
|
7405
7397
|
|
|
7406
7398
|
function getScopedNameGenerator(opts) {
|
|
7407
|
-
const scopedNameGenerator = opts.generateScopedName ||
|
|
7408
|
-
|
|
7399
|
+
const scopedNameGenerator = opts.generateScopedName || _generateScopedName.default;
|
|
7409
7400
|
if (typeof scopedNameGenerator === "function") return scopedNameGenerator;
|
|
7410
|
-
return (0,
|
|
7401
|
+
return (0, _genericNames.default)(scopedNameGenerator, {
|
|
7411
7402
|
context: process.cwd(),
|
|
7412
7403
|
hashPrefix: opts.hashPrefix
|
|
7413
7404
|
});
|
|
@@ -7415,7 +7406,7 @@ function getScopedNameGenerator(opts) {
|
|
|
7415
7406
|
|
|
7416
7407
|
function getLoader(opts, plugins) {
|
|
7417
7408
|
const root = typeof opts.root === "undefined" ? "/" : opts.root;
|
|
7418
|
-
return typeof opts.Loader === "function" ? new opts.Loader(root, plugins) : new
|
|
7409
|
+
return typeof opts.Loader === "function" ? new opts.Loader(root, plugins) : new _loader.default(root, plugins);
|
|
7419
7410
|
}
|
|
7420
7411
|
|
|
7421
7412
|
function isGlobalModule(globalModules, inputFile) {
|
|
@@ -7454,83 +7445,80 @@ function dashesCamelCase(string) {
|
|
|
7454
7445
|
build.exports = (opts = {}) => {
|
|
7455
7446
|
return {
|
|
7456
7447
|
postcssPlugin: PLUGIN_NAME,
|
|
7457
|
-
OnceExit(css, { result }) {
|
|
7458
|
-
return _asyncToGenerator(function* () {
|
|
7459
|
-
const getJSON = opts.getJSON || _saveJSON2.default;
|
|
7460
|
-
const inputFile = css.source.input.file;
|
|
7461
|
-
const pluginList = getDefaultPluginsList(opts, inputFile);
|
|
7462
|
-
const resultPluginIndex = result.processor.plugins.findIndex(function (plugin) {
|
|
7463
|
-
return isOurPlugin(plugin);
|
|
7464
|
-
});
|
|
7465
|
-
if (resultPluginIndex === -1) {
|
|
7466
|
-
throw new Error('Plugin missing from options.');
|
|
7467
|
-
}
|
|
7468
|
-
const earlierPlugins = result.processor.plugins.slice(0, resultPluginIndex);
|
|
7469
|
-
const loaderPlugins = [...earlierPlugins, ...pluginList];
|
|
7470
|
-
const loader = getLoader(opts, loaderPlugins);
|
|
7471
|
-
const fetcher = function fetcher(file, relativeTo, depTrace) {
|
|
7472
|
-
const unquoteFile = (0, _unquote2.default)(file);
|
|
7473
|
-
const resolvedResult = typeof opts.resolve === 'function' && opts.resolve(unquoteFile);
|
|
7474
|
-
const resolvedFile = resolvedResult instanceof Promise ? resolvedResult : Promise.resolve(resolvedResult);
|
|
7475
|
-
|
|
7476
|
-
return resolvedFile.then(function (f) {
|
|
7477
|
-
return loader.fetch.call(loader, `"${f || unquoteFile}"`, relativeTo, depTrace);
|
|
7478
|
-
});
|
|
7479
|
-
};
|
|
7480
|
-
const parser = new _parser2.default(fetcher);
|
|
7481
|
-
|
|
7482
|
-
yield (0, _postcss2.default)([...pluginList, parser.plugin()]).process(css, {
|
|
7483
|
-
from: inputFile
|
|
7484
|
-
});
|
|
7485
7448
|
|
|
7486
|
-
|
|
7487
|
-
|
|
7449
|
+
async OnceExit(css, {
|
|
7450
|
+
result
|
|
7451
|
+
}) {
|
|
7452
|
+
const getJSON = opts.getJSON || _saveJSON.default;
|
|
7453
|
+
const inputFile = css.source.input.file;
|
|
7454
|
+
const pluginList = getDefaultPluginsList(opts, inputFile);
|
|
7455
|
+
const resultPluginIndex = result.processor.plugins.findIndex(plugin => isOurPlugin(plugin));
|
|
7488
7456
|
|
|
7489
|
-
|
|
7490
|
-
|
|
7457
|
+
if (resultPluginIndex === -1) {
|
|
7458
|
+
throw new Error('Plugin missing from options.');
|
|
7459
|
+
}
|
|
7491
7460
|
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
|
|
7461
|
+
const earlierPlugins = result.processor.plugins.slice(0, resultPluginIndex);
|
|
7462
|
+
const loaderPlugins = [...earlierPlugins, ...pluginList];
|
|
7463
|
+
const loader = getLoader(opts, loaderPlugins);
|
|
7495
7464
|
|
|
7496
|
-
|
|
7497
|
-
|
|
7465
|
+
const fetcher = (file, relativeTo, depTrace) => {
|
|
7466
|
+
const unquoteFile = (0, _unquote.default)(file);
|
|
7467
|
+
const resolvedResult = typeof opts.resolve === 'function' && opts.resolve(unquoteFile);
|
|
7468
|
+
const resolvedFile = resolvedResult instanceof Promise ? resolvedResult : Promise.resolve(resolvedResult);
|
|
7469
|
+
return resolvedFile.then(f => {
|
|
7470
|
+
return loader.fetch.call(loader, `"${f || unquoteFile}"`, relativeTo, depTrace);
|
|
7471
|
+
});
|
|
7472
|
+
};
|
|
7498
7473
|
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
|
|
7474
|
+
const parser = new _parser.default(fetcher);
|
|
7475
|
+
await (0, _postcss.default)([...pluginList, parser.plugin()]).process(css, {
|
|
7476
|
+
from: inputFile
|
|
7477
|
+
});
|
|
7478
|
+
const out = loader.finalSource;
|
|
7479
|
+
if (out) css.prepend(out);
|
|
7480
|
+
|
|
7481
|
+
if (opts.localsConvention) {
|
|
7482
|
+
const isFunc = typeof opts.localsConvention === "function";
|
|
7483
|
+
parser.exportTokens = Object.entries(parser.exportTokens).reduce((tokens, [className, value]) => {
|
|
7484
|
+
if (isFunc) {
|
|
7485
|
+
tokens[opts.localsConvention(className, value, inputFile)] = value;
|
|
7486
|
+
return tokens;
|
|
7487
|
+
}
|
|
7503
7488
|
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
7489
|
+
switch (opts.localsConvention) {
|
|
7490
|
+
case "camelCase":
|
|
7491
|
+
tokens[className] = value;
|
|
7492
|
+
tokens[(0, _lodash.default)(className)] = value;
|
|
7493
|
+
break;
|
|
7507
7494
|
|
|
7508
|
-
|
|
7509
|
-
|
|
7510
|
-
|
|
7511
|
-
tokens[dashesCamelCase(className)] = value;
|
|
7495
|
+
case "camelCaseOnly":
|
|
7496
|
+
tokens[(0, _lodash.default)(className)] = value;
|
|
7497
|
+
break;
|
|
7512
7498
|
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
|
|
7499
|
+
case "dashes":
|
|
7500
|
+
tokens[className] = value;
|
|
7501
|
+
tokens[dashesCamelCase(className)] = value;
|
|
7502
|
+
break;
|
|
7516
7503
|
|
|
7517
|
-
|
|
7518
|
-
|
|
7504
|
+
case "dashesOnly":
|
|
7505
|
+
tokens[dashesCamelCase(className)] = value;
|
|
7506
|
+
break;
|
|
7507
|
+
}
|
|
7519
7508
|
|
|
7520
|
-
|
|
7521
|
-
|
|
7522
|
-
|
|
7509
|
+
return tokens;
|
|
7510
|
+
}, {});
|
|
7511
|
+
}
|
|
7523
7512
|
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
|
|
7528
|
-
|
|
7513
|
+
result.messages.push({
|
|
7514
|
+
type: "export",
|
|
7515
|
+
plugin: "postcss-modules",
|
|
7516
|
+
exportTokens: parser.exportTokens
|
|
7517
|
+
}); // getJSON may return a promise
|
|
7529
7518
|
|
|
7530
|
-
|
|
7531
|
-
return getJSON(css.source.input.file, parser.exportTokens, result.opts.to);
|
|
7532
|
-
})();
|
|
7519
|
+
return getJSON(css.source.input.file, parser.exportTokens, result.opts.to);
|
|
7533
7520
|
}
|
|
7521
|
+
|
|
7534
7522
|
};
|
|
7535
7523
|
};
|
|
7536
7524
|
|
package/dist/node/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { performance } from 'node:perf_hooks';
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
|
-
import { y as picocolors, u as createLogger, e as resolveConfig } from './chunks/dep-
|
|
3
|
+
import { y as picocolors, u as createLogger, e as resolveConfig } from './chunks/dep-3ffe6dd0.js';
|
|
4
4
|
import { VERSION } from './constants.js';
|
|
5
5
|
import 'node:fs';
|
|
6
6
|
import 'node:path';
|
|
@@ -25,13 +25,14 @@ import 'node:dns';
|
|
|
25
25
|
import 'resolve';
|
|
26
26
|
import 'crypto';
|
|
27
27
|
import 'buffer';
|
|
28
|
+
import 'node:buffer';
|
|
28
29
|
import 'module';
|
|
30
|
+
import 'worker_threads';
|
|
29
31
|
import 'zlib';
|
|
30
32
|
import 'https';
|
|
31
33
|
import 'tls';
|
|
32
34
|
import 'node:http';
|
|
33
35
|
import 'node:https';
|
|
34
|
-
import 'worker_threads';
|
|
35
36
|
import 'querystring';
|
|
36
37
|
import 'node:readline';
|
|
37
38
|
import 'node:child_process';
|
|
@@ -694,7 +695,7 @@ cli
|
|
|
694
695
|
.action(async (root, options) => {
|
|
695
696
|
// output structure is preserved even after bundling so require()
|
|
696
697
|
// is ok here
|
|
697
|
-
const { createServer } = await import('./chunks/dep-
|
|
698
|
+
const { createServer } = await import('./chunks/dep-3ffe6dd0.js').then(function (n) { return n.C; });
|
|
698
699
|
try {
|
|
699
700
|
const server = await createServer({
|
|
700
701
|
root,
|
|
@@ -741,7 +742,7 @@ cli
|
|
|
741
742
|
.option('--emptyOutDir', `[boolean] force empty outDir when it's outside of root`)
|
|
742
743
|
.option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
|
|
743
744
|
.action(async (root, options) => {
|
|
744
|
-
const { build } = await import('./chunks/dep-
|
|
745
|
+
const { build } = await import('./chunks/dep-3ffe6dd0.js').then(function (n) { return n.B; });
|
|
745
746
|
const buildOptions = cleanOptions(options);
|
|
746
747
|
try {
|
|
747
748
|
await build({
|
|
@@ -765,7 +766,7 @@ cli
|
|
|
765
766
|
.command('optimize [root]', 'pre-bundle dependencies')
|
|
766
767
|
.option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
|
|
767
768
|
.action(async (root, options) => {
|
|
768
|
-
const { optimizeDeps } = await import('./chunks/dep-
|
|
769
|
+
const { optimizeDeps } = await import('./chunks/dep-3ffe6dd0.js').then(function (n) { return n.A; });
|
|
769
770
|
try {
|
|
770
771
|
const config = await resolveConfig({
|
|
771
772
|
root,
|
|
@@ -788,7 +789,7 @@ cli
|
|
|
788
789
|
.option('--https', `[boolean] use TLS + HTTP/2`)
|
|
789
790
|
.option('--open [path]', `[boolean | string] open browser on startup`)
|
|
790
791
|
.action(async (root, options) => {
|
|
791
|
-
const { preview } = await import('./chunks/dep-
|
|
792
|
+
const { preview } = await import('./chunks/dep-3ffe6dd0.js').then(function (n) { return n.D; });
|
|
792
793
|
try {
|
|
793
794
|
const server = await preview({
|
|
794
795
|
root,
|