tailwindcss 0.0.0-oxide-insiders.694aea0 → 0.0.0-oxide-insiders.ac1738e
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/lib/cli/build/index.js +3 -2
- package/lib/cli/build/plugin.js +23 -18
- package/lib/cli/build/watching.js +1 -1
- package/lib/cli/index.js +12 -21
- package/lib/cli/init/index.js +21 -6
- package/lib/lib/getModuleDependencies.js +37 -25
- package/lib/lib/load-config.js +36 -0
- package/lib/lib/setupTrackingContext.js +4 -4
- package/lib/oxide/cli/build/index.js +3 -2
- package/lib/oxide/cli/build/plugin.js +22 -17
- package/lib/oxide/cli/build/watching.js +1 -1
- package/lib/oxide/cli/index.js +10 -16
- package/lib/oxide/cli/init/index.js +19 -4
- package/lib/public/default-config.js +2 -2
- package/lib/public/default-theme.js +2 -2
- package/lib/public/load-config.js +10 -0
- package/lib/util/getAllConfigs.js +2 -2
- package/lib/util/resolveConfigPath.js +19 -7
- package/loadConfig.d.ts +4 -0
- package/loadConfig.js +2 -0
- package/package.json +7 -5
- package/src/cli/build/index.js +3 -6
- package/src/cli/build/plugin.js +23 -22
- package/src/cli/build/watching.js +1 -1
- package/src/cli/index.js +8 -26
- package/src/cli/init/index.js +37 -8
- package/src/lib/getModuleDependencies.js +26 -25
- package/src/lib/load-config.ts +27 -0
- package/src/lib/setupTrackingContext.js +4 -4
- package/src/oxide/cli/build/index.ts +3 -6
- package/src/oxide/cli/build/plugin.ts +23 -21
- package/src/oxide/cli/build/watching.ts +1 -1
- package/src/oxide/cli/index.ts +7 -15
- package/src/oxide/cli/init/index.ts +34 -7
- package/src/public/default-config.js +1 -1
- package/src/public/default-theme.js +2 -2
- package/src/public/load-config.js +2 -0
- package/src/util/getAllConfigs.js +2 -2
- package/src/util/resolveConfigPath.js +12 -1
- package/stubs/.gitignore +1 -0
- package/stubs/.prettierrc.json +6 -0
- package/stubs/{defaultConfig.stub.js → config.full.js} +0 -1
- package/stubs/{simpleConfig.stub.js → config.simple.js} +0 -1
- package/stubs/postcss.config.js +6 -0
- package/stubs/tailwind.config.cjs +2 -0
- package/stubs/tailwind.config.js +2 -0
- package/stubs/tailwind.config.ts +3 -0
- package/lib/constants.js +0 -44
- package/src/constants.js +0 -17
- /package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -0
package/lib/cli/build/index.js
CHANGED
|
@@ -9,13 +9,14 @@ Object.defineProperty(exports, "build", {
|
|
|
9
9
|
});
|
|
10
10
|
const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
11
11
|
const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
12
|
+
const _resolveConfigPathJs = require("../../util/resolveConfigPath.js");
|
|
12
13
|
const _pluginJs = require("./plugin.js");
|
|
13
14
|
function _interopRequireDefault(obj) {
|
|
14
15
|
return obj && obj.__esModule ? obj : {
|
|
15
16
|
default: obj
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
|
-
async function build(args
|
|
19
|
+
async function build(args) {
|
|
19
20
|
let input = args["--input"];
|
|
20
21
|
let shouldWatch = args["--watch"];
|
|
21
22
|
// TODO: Deprecate this in future versions
|
|
@@ -32,7 +33,7 @@ async function build(args, configs) {
|
|
|
32
33
|
process.exit(9);
|
|
33
34
|
}
|
|
34
35
|
// TODO: Reference the @config path here if exists
|
|
35
|
-
let configPath = args["--config"] ? args["--config"] : (
|
|
36
|
+
let configPath = args["--config"] ? args["--config"] : (0, _resolveConfigPathJs.resolveDefaultConfigPath)();
|
|
36
37
|
let processor = await (0, _pluginJs.createProcessor)(args, configPath);
|
|
37
38
|
if (shouldWatch) {
|
|
38
39
|
// Abort the watcher if stdin is closed to avoid zombie processes
|
package/lib/cli/build/plugin.js
CHANGED
|
@@ -20,12 +20,13 @@ const _deps = require("./deps");
|
|
|
20
20
|
const _utils = require("./utils");
|
|
21
21
|
const _sharedState = require("../../lib/sharedState");
|
|
22
22
|
const _resolveConfigJs = /*#__PURE__*/ _interopRequireDefault(require("../../../resolveConfig.js"));
|
|
23
|
-
const _getModuleDependenciesJs = /*#__PURE__*/ _interopRequireDefault(require("../../lib/getModuleDependencies.js"));
|
|
24
23
|
const _contentJs = require("../../lib/content.js");
|
|
25
24
|
const _watchingJs = require("./watching.js");
|
|
26
25
|
const _fastGlob = /*#__PURE__*/ _interopRequireDefault(require("fast-glob"));
|
|
27
26
|
const _findAtConfigPathJs = require("../../lib/findAtConfigPath.js");
|
|
28
27
|
const _log = /*#__PURE__*/ _interopRequireDefault(require("../../util/log"));
|
|
28
|
+
const _loadConfig = require("../../lib/load-config");
|
|
29
|
+
const _getModuleDependencies = /*#__PURE__*/ _interopRequireDefault(require("../../lib/getModuleDependencies"));
|
|
29
30
|
function _interopRequireDefault(obj) {
|
|
30
31
|
return obj && obj.__esModule ? obj : {
|
|
31
32
|
default: obj
|
|
@@ -109,7 +110,7 @@ let state = {
|
|
|
109
110
|
/** @type {any} */ context: null,
|
|
110
111
|
/** @type {ReturnType<typeof createWatcher> | null} */ watcher: null,
|
|
111
112
|
/** @type {{content: string, extension: string}[]} */ changedContent: [],
|
|
112
|
-
|
|
113
|
+
/** @type {ReturnType<typeof load> | null} */ configBag: null,
|
|
113
114
|
contextDependencies: new Set(),
|
|
114
115
|
/** @type {import('../../lib/content.js').ContentPath[]} */ contentPaths: [],
|
|
115
116
|
refreshContentPaths () {
|
|
@@ -127,32 +128,35 @@ let state = {
|
|
|
127
128
|
},
|
|
128
129
|
loadConfig (configPath, content) {
|
|
129
130
|
if (this.watcher && configPath) {
|
|
130
|
-
this.refreshConfigDependencies(
|
|
131
|
+
this.refreshConfigDependencies();
|
|
131
132
|
}
|
|
132
|
-
let config =
|
|
133
|
+
let config = (0, _loadConfig.loadConfig)(configPath);
|
|
134
|
+
let dependencies = (0, _getModuleDependencies.default)(configPath);
|
|
135
|
+
this.configBag = {
|
|
136
|
+
config,
|
|
137
|
+
dependencies,
|
|
138
|
+
dispose () {
|
|
139
|
+
for (let file of dependencies){
|
|
140
|
+
delete require.cache[require.resolve(file)];
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
};
|
|
133
144
|
// @ts-ignore
|
|
134
|
-
config = (0, _resolveConfigJs.default)(config, {
|
|
145
|
+
this.configBag.config = (0, _resolveConfigJs.default)(this.configBag.config, {
|
|
135
146
|
content: {
|
|
136
147
|
files: []
|
|
137
148
|
}
|
|
138
149
|
});
|
|
139
150
|
// Override content files if `--content` has been passed explicitly
|
|
140
151
|
if ((content === null || content === void 0 ? void 0 : content.length) > 0) {
|
|
141
|
-
config.content.files = content;
|
|
152
|
+
this.configBag.config.content.files = content;
|
|
142
153
|
}
|
|
143
|
-
return config;
|
|
154
|
+
return this.configBag.config;
|
|
144
155
|
},
|
|
145
|
-
refreshConfigDependencies (
|
|
156
|
+
refreshConfigDependencies () {
|
|
157
|
+
var _this_configBag;
|
|
146
158
|
_sharedState.env.DEBUG && console.time("Module dependencies");
|
|
147
|
-
|
|
148
|
-
delete require.cache[require.resolve(file)];
|
|
149
|
-
}
|
|
150
|
-
if (configPath) {
|
|
151
|
-
let deps = (0, _getModuleDependenciesJs.default)(configPath).map(({ file })=>file);
|
|
152
|
-
for (let dependency of deps){
|
|
153
|
-
this.configDependencies.add(dependency);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
159
|
+
(_this_configBag = this.configBag) === null || _this_configBag === void 0 ? void 0 : _this_configBag.dispose();
|
|
156
160
|
_sharedState.env.DEBUG && console.timeEnd("Module dependencies");
|
|
157
161
|
},
|
|
158
162
|
readContentPaths () {
|
|
@@ -353,7 +357,8 @@ async function createProcessor(args, cliConfigPath) {
|
|
|
353
357
|
* @param {{file: string, content(): Promise<string>, extension: string}[]} changes
|
|
354
358
|
*/ async rebuild (changes) {
|
|
355
359
|
let needsNewContext = changes.some((change)=>{
|
|
356
|
-
|
|
360
|
+
var _state_configBag;
|
|
361
|
+
return ((_state_configBag = state.configBag) === null || _state_configBag === void 0 ? void 0 : _state_configBag.dependencies.has(change.file)) || state.contextDependencies.has(change.file);
|
|
357
362
|
});
|
|
358
363
|
if (needsNewContext) {
|
|
359
364
|
state.context = null;
|
|
@@ -171,7 +171,7 @@ function createWatcher(args, { state , rebuild }) {
|
|
|
171
171
|
fswatcher: watcher,
|
|
172
172
|
refreshWatchedFiles () {
|
|
173
173
|
watcher.add(Array.from(state.contextDependencies));
|
|
174
|
-
watcher.add(Array.from(state.
|
|
174
|
+
watcher.add(Array.from(state.configBag.dependencies));
|
|
175
175
|
watcher.add(state.contentPatterns.all);
|
|
176
176
|
}
|
|
177
177
|
};
|
package/lib/cli/index.js
CHANGED
|
@@ -14,23 +14,6 @@ function _interopRequireDefault(obj) {
|
|
|
14
14
|
default: obj
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
function isESM() {
|
|
18
|
-
const pkgPath = _path.default.resolve("./package.json");
|
|
19
|
-
try {
|
|
20
|
-
let pkg = JSON.parse(_fs.default.readFileSync(pkgPath, "utf8"));
|
|
21
|
-
return pkg.type && pkg.type === "module";
|
|
22
|
-
} catch (err) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
let configs = isESM() ? {
|
|
27
|
-
tailwind: "tailwind.config.cjs",
|
|
28
|
-
postcss: "postcss.config.cjs"
|
|
29
|
-
} : {
|
|
30
|
-
tailwind: "tailwind.config.js",
|
|
31
|
-
postcss: "postcss.config.js"
|
|
32
|
-
};
|
|
33
|
-
// ---
|
|
34
17
|
function oneOf(...options) {
|
|
35
18
|
return Object.assign((value = true)=>{
|
|
36
19
|
for (let option of options){
|
|
@@ -48,13 +31,21 @@ let commands = {
|
|
|
48
31
|
init: {
|
|
49
32
|
run: _init.init,
|
|
50
33
|
args: {
|
|
51
|
-
"--
|
|
34
|
+
"--esm": {
|
|
52
35
|
type: Boolean,
|
|
53
|
-
description: `Initialize
|
|
36
|
+
description: `Initialize configuration file as ESM`
|
|
37
|
+
},
|
|
38
|
+
"--ts": {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
description: `Initialize configuration file as TypeScript`
|
|
54
41
|
},
|
|
55
42
|
"--postcss": {
|
|
56
43
|
type: Boolean,
|
|
57
|
-
description: `Initialize a
|
|
44
|
+
description: `Initialize a \`postcss.config.js\` file`
|
|
45
|
+
},
|
|
46
|
+
"--full": {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
description: `Include the default values for all options in the generated configuration file`
|
|
58
49
|
},
|
|
59
50
|
"-f": "--full",
|
|
60
51
|
"-p": "--postcss"
|
|
@@ -236,4 +227,4 @@ if (args["--help"]) {
|
|
|
236
227
|
});
|
|
237
228
|
process.exit(0);
|
|
238
229
|
}
|
|
239
|
-
run(args
|
|
230
|
+
run(args);
|
package/lib/cli/init/index.js
CHANGED
|
@@ -14,25 +14,40 @@ function _interopRequireDefault(obj) {
|
|
|
14
14
|
default: obj
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function isESM() {
|
|
18
|
+
const pkgPath = _path.default.resolve("./package.json");
|
|
19
|
+
try {
|
|
20
|
+
let pkg = JSON.parse(_fs.default.readFileSync(pkgPath, "utf8"));
|
|
21
|
+
return pkg.type && pkg.type === "module";
|
|
22
|
+
} catch (err) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function init(args) {
|
|
18
27
|
let messages = [];
|
|
28
|
+
let isProjectESM = args["--ts"] || args["--esm"] || isESM();
|
|
29
|
+
let syntax = args["--ts"] ? "ts" : isProjectESM ? "js" : "cjs";
|
|
30
|
+
let extension = args["--ts"] ? "ts" : "js";
|
|
19
31
|
var _args___;
|
|
20
|
-
let tailwindConfigLocation = _path.default.resolve((_args___ = args["_"][1]) !== null && _args___ !== void 0 ? _args___ :
|
|
32
|
+
let tailwindConfigLocation = _path.default.resolve((_args___ = args["_"][1]) !== null && _args___ !== void 0 ? _args___ : `./tailwind.config.${extension}`);
|
|
21
33
|
if (_fs.default.existsSync(tailwindConfigLocation)) {
|
|
22
34
|
messages.push(`${_path.default.basename(tailwindConfigLocation)} already exists.`);
|
|
23
35
|
} else {
|
|
24
|
-
let
|
|
36
|
+
let stubContentsFile = _fs.default.readFileSync(args["--full"] ? _path.default.resolve(__dirname, "../../../stubs/config.full.js") : _path.default.resolve(__dirname, "../../../stubs/config.simple.js"), "utf8");
|
|
37
|
+
let stubFile = _fs.default.readFileSync(_path.default.resolve(__dirname, `../../../stubs/tailwind.config.${syntax}`), "utf8");
|
|
25
38
|
// Change colors import
|
|
26
|
-
|
|
39
|
+
stubContentsFile = stubContentsFile.replace("../colors", "tailwindcss/colors");
|
|
40
|
+
// Replace contents of {ts,js,cjs} file with the stub {simple,full}.
|
|
41
|
+
stubFile = stubFile.replace("__CONFIG__", stubContentsFile.replace("module.exports =", "").trim()).trim() + "\n\n";
|
|
27
42
|
_fs.default.writeFileSync(tailwindConfigLocation, stubFile, "utf8");
|
|
28
43
|
messages.push(`Created Tailwind CSS config file: ${_path.default.basename(tailwindConfigLocation)}`);
|
|
29
44
|
}
|
|
30
45
|
if (args["--postcss"]) {
|
|
31
|
-
let postcssConfigLocation = _path.default.resolve(
|
|
46
|
+
let postcssConfigLocation = _path.default.resolve("./postcss.config.js");
|
|
32
47
|
if (_fs.default.existsSync(postcssConfigLocation)) {
|
|
33
48
|
messages.push(`${_path.default.basename(postcssConfigLocation)} already exists.`);
|
|
34
49
|
} else {
|
|
35
|
-
let stubFile = _fs.default.readFileSync(_path.default.resolve(__dirname, "../../../stubs/
|
|
50
|
+
let stubFile = _fs.default.readFileSync(isProjectESM ? _path.default.resolve(__dirname, "../../../stubs/postcss.config.js") : _path.default.resolve(__dirname, "../../../stubs/postcss.config.cjs"), "utf8");
|
|
36
51
|
_fs.default.writeFileSync(postcssConfigLocation, stubFile, "utf8");
|
|
37
52
|
messages.push(`Created PostCSS config file: ${_path.default.basename(postcssConfigLocation)}`);
|
|
38
53
|
}
|
|
@@ -9,43 +9,55 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
10
10
|
const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
11
11
|
const _resolve = /*#__PURE__*/ _interopRequireDefault(require("resolve"));
|
|
12
|
-
const
|
|
12
|
+
const _detectiveTypescript = /*#__PURE__*/ _interopRequireDefault(require("detective-typescript"));
|
|
13
13
|
function _interopRequireDefault(obj) {
|
|
14
14
|
return obj && obj.__esModule ? obj : {
|
|
15
15
|
default: obj
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
function createModule(file) {
|
|
19
|
-
|
|
20
|
-
const requires = (0, _detective.default)(source);
|
|
19
|
+
let source = _fs.default.readFileSync(file, "utf-8");
|
|
21
20
|
return {
|
|
22
21
|
file,
|
|
23
|
-
requires
|
|
22
|
+
requires: (0, _detectiveTypescript.default)(source, {
|
|
23
|
+
mixedImports: true
|
|
24
|
+
})
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
function* _getModuleDependencies(entryFile) {
|
|
28
|
+
yield entryFile;
|
|
29
|
+
let mod = createModule(entryFile);
|
|
30
|
+
let ext = _path.default.extname(entryFile);
|
|
31
|
+
let isTypeScript = ext === ".ts" || ext === ".cts" || ext === ".mts";
|
|
32
|
+
let extensions = [
|
|
33
|
+
...isTypeScript ? [
|
|
34
|
+
".ts",
|
|
35
|
+
".cts",
|
|
36
|
+
".mts"
|
|
37
|
+
] : [],
|
|
38
|
+
".js",
|
|
39
|
+
".cjs",
|
|
40
|
+
".mjs"
|
|
30
41
|
];
|
|
31
42
|
// Iterate over the modules, even when new
|
|
32
43
|
// ones are being added
|
|
33
|
-
for (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
44
|
+
for (let dep of mod.requires){
|
|
45
|
+
// Only track local modules, not node_modules
|
|
46
|
+
if (!dep.startsWith("./") && !dep.startsWith("../")) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
let basedir = _path.default.dirname(mod.file);
|
|
51
|
+
let depPath = _resolve.default.sync(dep, {
|
|
52
|
+
basedir,
|
|
53
|
+
extensions
|
|
54
|
+
});
|
|
55
|
+
yield* _getModuleDependencies(depPath);
|
|
56
|
+
} catch (_err) {
|
|
57
|
+
// eslint-disable-next-line no-empty
|
|
58
|
+
}
|
|
49
59
|
}
|
|
50
|
-
|
|
60
|
+
}
|
|
61
|
+
function getModuleDependencies(entryFile) {
|
|
62
|
+
return new Set(_getModuleDependencies(entryFile));
|
|
51
63
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "loadConfig", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>loadConfig
|
|
8
|
+
});
|
|
9
|
+
const _jiti = /*#__PURE__*/ _interopRequireDefault(require("jiti"));
|
|
10
|
+
const _sucrase = require("sucrase");
|
|
11
|
+
function _interopRequireDefault(obj) {
|
|
12
|
+
return obj && obj.__esModule ? obj : {
|
|
13
|
+
default: obj
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
let jiti = null;
|
|
17
|
+
function lazyJiti() {
|
|
18
|
+
return jiti !== null && jiti !== void 0 ? jiti : jiti = (0, _jiti.default)(__filename, {
|
|
19
|
+
interopDefault: true,
|
|
20
|
+
transform: (opts)=>{
|
|
21
|
+
return (0, _sucrase.transform)(opts.source, {
|
|
22
|
+
transforms: [
|
|
23
|
+
"typescript",
|
|
24
|
+
"imports"
|
|
25
|
+
]
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function loadConfig(path) {
|
|
31
|
+
try {
|
|
32
|
+
return path ? require(path) : {};
|
|
33
|
+
} catch {
|
|
34
|
+
return lazyJiti()(path);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -14,13 +14,14 @@ Object.defineProperty(exports, // DISABLE_TOUCH = TRUE
|
|
|
14
14
|
const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
15
15
|
const _quickLru = /*#__PURE__*/ _interopRequireDefault(require("quick-lru"));
|
|
16
16
|
const _hashConfig = /*#__PURE__*/ _interopRequireDefault(require("../util/hashConfig"));
|
|
17
|
-
const _getModuleDependencies = /*#__PURE__*/ _interopRequireDefault(require("../lib/getModuleDependencies"));
|
|
18
17
|
const _resolveConfig = /*#__PURE__*/ _interopRequireDefault(require("../public/resolve-config"));
|
|
19
18
|
const _resolveConfigPath = /*#__PURE__*/ _interopRequireDefault(require("../util/resolveConfigPath"));
|
|
20
19
|
const _setupContextUtils = require("./setupContextUtils");
|
|
21
20
|
const _parseDependency = /*#__PURE__*/ _interopRequireDefault(require("../util/parseDependency"));
|
|
22
21
|
const _validateConfigJs = require("../util/validateConfig.js");
|
|
23
22
|
const _contentJs = require("./content.js");
|
|
23
|
+
const _loadConfig = require("../lib/load-config");
|
|
24
|
+
const _getModuleDependencies = /*#__PURE__*/ _interopRequireDefault(require("./getModuleDependencies"));
|
|
24
25
|
function _interopRequireDefault(obj) {
|
|
25
26
|
return obj && obj.__esModule ? obj : {
|
|
26
27
|
default: obj
|
|
@@ -42,7 +43,7 @@ function getTailwindConfig(configOrPath) {
|
|
|
42
43
|
let userConfigPath = (0, _resolveConfigPath.default)(configOrPath);
|
|
43
44
|
if (userConfigPath !== null) {
|
|
44
45
|
let [prevConfig, prevConfigHash, prevDeps, prevModified] = configPathCache.get(userConfigPath) || [];
|
|
45
|
-
let newDeps = (0, _getModuleDependencies.default)(userConfigPath)
|
|
46
|
+
let newDeps = (0, _getModuleDependencies.default)(userConfigPath);
|
|
46
47
|
let modified = false;
|
|
47
48
|
let newModified = new Map();
|
|
48
49
|
for (let file of newDeps){
|
|
@@ -65,8 +66,7 @@ function getTailwindConfig(configOrPath) {
|
|
|
65
66
|
for (let file of newDeps){
|
|
66
67
|
delete require.cache[file];
|
|
67
68
|
}
|
|
68
|
-
let newConfig = (0, _resolveConfig.default)(
|
|
69
|
-
newConfig = (0, _validateConfigJs.validateConfig)(newConfig);
|
|
69
|
+
let newConfig = (0, _validateConfigJs.validateConfig)((0, _resolveConfig.default)((0, _loadConfig.loadConfig)(userConfigPath)));
|
|
70
70
|
let newHash = (0, _hashConfig.default)(newConfig);
|
|
71
71
|
configPathCache.set(userConfigPath, [
|
|
72
72
|
newConfig,
|
|
@@ -8,13 +8,14 @@ Object.defineProperty(exports, "build", {
|
|
|
8
8
|
});
|
|
9
9
|
const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
10
10
|
const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
11
|
+
const _resolveConfigPath = require("../../../util/resolveConfigPath");
|
|
11
12
|
const _plugin = require("./plugin");
|
|
12
13
|
function _interopRequireDefault(obj) {
|
|
13
14
|
return obj && obj.__esModule ? obj : {
|
|
14
15
|
default: obj
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
|
-
async function build(args
|
|
18
|
+
async function build(args) {
|
|
18
19
|
let input = args["--input"];
|
|
19
20
|
let shouldWatch = args["--watch"];
|
|
20
21
|
// TODO: Deprecate this in future versions
|
|
@@ -31,7 +32,7 @@ async function build(args, configs) {
|
|
|
31
32
|
process.exit(9);
|
|
32
33
|
}
|
|
33
34
|
// TODO: Reference the @config path here if exists
|
|
34
|
-
let configPath = args["--config"] ? args["--config"] : (
|
|
35
|
+
let configPath = args["--config"] ? args["--config"] : (0, _resolveConfigPath.resolveDefaultConfigPath)();
|
|
35
36
|
let processor = await (0, _plugin.createProcessor)(args, configPath);
|
|
36
37
|
if (shouldWatch) {
|
|
37
38
|
// Abort the watcher if stdin is closed to avoid zombie processes
|
|
@@ -19,12 +19,13 @@ const _deps = require("./deps");
|
|
|
19
19
|
const _utils = require("./utils");
|
|
20
20
|
const _sharedState = require("../../../lib/sharedState");
|
|
21
21
|
const _resolveConfig = /*#__PURE__*/ _interopRequireDefault(require("../../../../resolveConfig"));
|
|
22
|
-
const _getModuleDependencies = /*#__PURE__*/ _interopRequireDefault(require("../../../lib/getModuleDependencies"));
|
|
23
22
|
const _content = require("../../../lib/content");
|
|
24
23
|
const _watching = require("./watching");
|
|
25
24
|
const _fastGlob = /*#__PURE__*/ _interopRequireDefault(require("fast-glob"));
|
|
26
25
|
const _findAtConfigPath = require("../../../lib/findAtConfigPath");
|
|
27
26
|
const _log = /*#__PURE__*/ _interopRequireDefault(require("../../../util/log"));
|
|
27
|
+
const _loadConfig = require("../../../lib/load-config");
|
|
28
|
+
const _getModuleDependencies = /*#__PURE__*/ _interopRequireDefault(require("../../../lib/getModuleDependencies"));
|
|
28
29
|
function _interopRequireDefault(obj) {
|
|
29
30
|
return obj && obj.__esModule ? obj : {
|
|
30
31
|
default: obj
|
|
@@ -108,7 +109,7 @@ let state = {
|
|
|
108
109
|
/** @type {any} */ context: null,
|
|
109
110
|
/** @type {ReturnType<typeof createWatcher> | null} */ watcher: null,
|
|
110
111
|
/** @type {{content: string, extension: string}[]} */ changedContent: [],
|
|
111
|
-
|
|
112
|
+
/** @type {{config: Config, dependencies: Set<string>, dispose: Function } | null} */ configBag: null,
|
|
112
113
|
contextDependencies: new Set(),
|
|
113
114
|
/** @type {import('../../lib/content.js').ContentPath[]} */ contentPaths: [],
|
|
114
115
|
refreshContentPaths () {
|
|
@@ -126,32 +127,35 @@ let state = {
|
|
|
126
127
|
},
|
|
127
128
|
loadConfig (configPath, content) {
|
|
128
129
|
if (this.watcher && configPath) {
|
|
129
|
-
this.refreshConfigDependencies(
|
|
130
|
+
this.refreshConfigDependencies();
|
|
130
131
|
}
|
|
131
|
-
let config =
|
|
132
|
+
let config = (0, _loadConfig.loadConfig)(configPath);
|
|
133
|
+
let dependencies = (0, _getModuleDependencies.default)(configPath);
|
|
134
|
+
this.configBag = {
|
|
135
|
+
config,
|
|
136
|
+
dependencies,
|
|
137
|
+
dispose () {
|
|
138
|
+
for (let file of dependencies){
|
|
139
|
+
delete require.cache[require.resolve(file)];
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
};
|
|
132
143
|
// @ts-ignore
|
|
133
|
-
config = (0, _resolveConfig.default)(config, {
|
|
144
|
+
this.configBag.config = (0, _resolveConfig.default)(this.configBag.config, {
|
|
134
145
|
content: {
|
|
135
146
|
files: []
|
|
136
147
|
}
|
|
137
148
|
});
|
|
138
149
|
// Override content files if `--content` has been passed explicitly
|
|
139
150
|
if ((content === null || content === void 0 ? void 0 : content.length) > 0) {
|
|
140
|
-
config.content.files = content;
|
|
151
|
+
this.configBag.config.content.files = content;
|
|
141
152
|
}
|
|
142
|
-
return config;
|
|
153
|
+
return this.configBag.config;
|
|
143
154
|
},
|
|
144
155
|
refreshConfigDependencies (configPath) {
|
|
156
|
+
var _this_configBag;
|
|
145
157
|
_sharedState.env.DEBUG && console.time("Module dependencies");
|
|
146
|
-
|
|
147
|
-
delete require.cache[require.resolve(file)];
|
|
148
|
-
}
|
|
149
|
-
if (configPath) {
|
|
150
|
-
let deps = (0, _getModuleDependencies.default)(configPath).map(({ file })=>file);
|
|
151
|
-
for (let dependency of deps){
|
|
152
|
-
this.configDependencies.add(dependency);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
158
|
+
(_this_configBag = this.configBag) === null || _this_configBag === void 0 ? void 0 : _this_configBag.dispose();
|
|
155
159
|
_sharedState.env.DEBUG && console.timeEnd("Module dependencies");
|
|
156
160
|
},
|
|
157
161
|
readContentPaths () {
|
|
@@ -350,7 +354,8 @@ async function createProcessor(args, cliConfigPath) {
|
|
|
350
354
|
* @param {{file: string, content(): Promise<string>, extension: string}[]} changes
|
|
351
355
|
*/ async rebuild (changes) {
|
|
352
356
|
let needsNewContext = changes.some((change)=>{
|
|
353
|
-
|
|
357
|
+
var _state_configBag;
|
|
358
|
+
return ((_state_configBag = state.configBag) === null || _state_configBag === void 0 ? void 0 : _state_configBag.dependencies.has(change.file)) || state.contextDependencies.has(change.file);
|
|
354
359
|
});
|
|
355
360
|
if (needsNewContext) {
|
|
356
361
|
state.context = null;
|
|
@@ -170,7 +170,7 @@ function createWatcher(args, { state , rebuild }) {
|
|
|
170
170
|
fswatcher: watcher,
|
|
171
171
|
refreshWatchedFiles () {
|
|
172
172
|
watcher.add(Array.from(state.contextDependencies));
|
|
173
|
-
watcher.add(Array.from(state.
|
|
173
|
+
watcher.add(Array.from(state.configBag.dependencies));
|
|
174
174
|
watcher.add(state.contentPatterns.all);
|
|
175
175
|
}
|
|
176
176
|
};
|
package/lib/oxide/cli/index.js
CHANGED
|
@@ -14,20 +14,6 @@ function _interopRequireDefault(obj) {
|
|
|
14
14
|
default: obj
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
function isESM() {
|
|
18
|
-
const pkgPath = _path.default.resolve("./package.json");
|
|
19
|
-
try {
|
|
20
|
-
let pkg = JSON.parse(_fs.default.readFileSync(pkgPath, "utf8"));
|
|
21
|
-
return pkg.type && pkg.type === "module";
|
|
22
|
-
} catch (err) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
let configs = isESM() ? {
|
|
27
|
-
tailwind: "tailwind.config.cjs"
|
|
28
|
-
} : {
|
|
29
|
-
tailwind: "tailwind.config.js"
|
|
30
|
-
};
|
|
31
17
|
// ---
|
|
32
18
|
function oneOf(...options) {
|
|
33
19
|
return Object.assign((value = true)=>{
|
|
@@ -46,9 +32,17 @@ let commands = {
|
|
|
46
32
|
init: {
|
|
47
33
|
run: _init.init,
|
|
48
34
|
args: {
|
|
35
|
+
"--esm": {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
description: `Initialize configuration file as ESM`
|
|
38
|
+
},
|
|
39
|
+
"--ts": {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
description: `Initialize configuration file as TypeScript`
|
|
42
|
+
},
|
|
49
43
|
"--full": {
|
|
50
44
|
type: Boolean,
|
|
51
|
-
description: `
|
|
45
|
+
description: `Include the default values for all options in the generated configuration file`
|
|
52
46
|
},
|
|
53
47
|
"-f": "--full"
|
|
54
48
|
}
|
|
@@ -217,4 +211,4 @@ if (args["--help"]) {
|
|
|
217
211
|
});
|
|
218
212
|
process.exit(0);
|
|
219
213
|
}
|
|
220
|
-
run(args
|
|
214
|
+
run(args);
|
|
@@ -13,16 +13,31 @@ function _interopRequireDefault(obj) {
|
|
|
13
13
|
default: obj
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function isESM() {
|
|
17
|
+
const pkgPath = _path.default.resolve("./package.json");
|
|
18
|
+
try {
|
|
19
|
+
let pkg = JSON.parse(_fs.default.readFileSync(pkgPath, "utf8"));
|
|
20
|
+
return pkg.type && pkg.type === "module";
|
|
21
|
+
} catch (err) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function init(args) {
|
|
17
26
|
let messages = [];
|
|
27
|
+
let isProjectESM = args["--ts"] || args["--esm"] || isESM();
|
|
28
|
+
let syntax = args["--ts"] ? "ts" : isProjectESM ? "js" : "cjs";
|
|
29
|
+
let extension = args["--ts"] ? "ts" : "js";
|
|
18
30
|
var _args___;
|
|
19
|
-
let tailwindConfigLocation = _path.default.resolve((_args___ = args["_"][1]) !== null && _args___ !== void 0 ? _args___ :
|
|
31
|
+
let tailwindConfigLocation = _path.default.resolve((_args___ = args["_"][1]) !== null && _args___ !== void 0 ? _args___ : `./tailwind.config.${extension}`);
|
|
20
32
|
if (_fs.default.existsSync(tailwindConfigLocation)) {
|
|
21
33
|
messages.push(`${_path.default.basename(tailwindConfigLocation)} already exists.`);
|
|
22
34
|
} else {
|
|
23
|
-
let
|
|
35
|
+
let stubContentsFile = _fs.default.readFileSync(args["--full"] ? _path.default.resolve(__dirname, "../../../../stubs/config.full.js") : _path.default.resolve(__dirname, "../../../../stubs/config.simple.js"), "utf8");
|
|
36
|
+
let stubFile = _fs.default.readFileSync(_path.default.resolve(__dirname, `../../../../stubs/tailwind.config.${syntax}`), "utf8");
|
|
24
37
|
// Change colors import
|
|
25
|
-
|
|
38
|
+
stubContentsFile = stubContentsFile.replace("../colors", "tailwindcss/colors");
|
|
39
|
+
// Replace contents of {ts,js,cjs} file with the stub {simple,full}.
|
|
40
|
+
stubFile = stubFile.replace("__CONFIG__", stubContentsFile.replace("module.exports =", "").trim()).trim() + "\n\n";
|
|
26
41
|
_fs.default.writeFileSync(tailwindConfigLocation, stubFile, "utf8");
|
|
27
42
|
messages.push(`Created Tailwind CSS config file: ${_path.default.basename(tailwindConfigLocation)}`);
|
|
28
43
|
}
|
|
@@ -7,10 +7,10 @@ Object.defineProperty(exports, "default", {
|
|
|
7
7
|
get: ()=>_default
|
|
8
8
|
});
|
|
9
9
|
const _cloneDeep = require("../util/cloneDeep");
|
|
10
|
-
const
|
|
10
|
+
const _configFull = /*#__PURE__*/ _interopRequireDefault(require("../../stubs/config.full"));
|
|
11
11
|
function _interopRequireDefault(obj) {
|
|
12
12
|
return obj && obj.__esModule ? obj : {
|
|
13
13
|
default: obj
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
const _default = (0, _cloneDeep.cloneDeep)(
|
|
16
|
+
const _default = (0, _cloneDeep.cloneDeep)(_configFull.default);
|
|
@@ -7,10 +7,10 @@ Object.defineProperty(exports, "default", {
|
|
|
7
7
|
get: ()=>_default
|
|
8
8
|
});
|
|
9
9
|
const _cloneDeep = require("../util/cloneDeep");
|
|
10
|
-
const
|
|
10
|
+
const _configFull = /*#__PURE__*/ _interopRequireDefault(require("../../stubs/config.full"));
|
|
11
11
|
function _interopRequireDefault(obj) {
|
|
12
12
|
return obj && obj.__esModule ? obj : {
|
|
13
13
|
default: obj
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
const _default = (0, _cloneDeep.cloneDeep)(
|
|
16
|
+
const _default = (0, _cloneDeep.cloneDeep)(_configFull.default.theme);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>_default
|
|
8
|
+
});
|
|
9
|
+
const _loadConfig = require("../lib/load-config");
|
|
10
|
+
const _default = _loadConfig.loadConfig;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "default", {
|
|
|
6
6
|
enumerable: true,
|
|
7
7
|
get: ()=>getAllConfigs
|
|
8
8
|
});
|
|
9
|
-
const
|
|
9
|
+
const _configFullJs = /*#__PURE__*/ _interopRequireDefault(require("../../stubs/config.full.js"));
|
|
10
10
|
const _featureFlags = require("../featureFlags");
|
|
11
11
|
function _interopRequireDefault(obj) {
|
|
12
12
|
return obj && obj.__esModule ? obj : {
|
|
@@ -16,7 +16,7 @@ function _interopRequireDefault(obj) {
|
|
|
16
16
|
function getAllConfigs(config) {
|
|
17
17
|
var _config_presets;
|
|
18
18
|
const configs = ((_config_presets = config === null || config === void 0 ? void 0 : config.presets) !== null && _config_presets !== void 0 ? _config_presets : [
|
|
19
|
-
|
|
19
|
+
_configFullJs.default
|
|
20
20
|
]).slice().reverse().flatMap((preset)=>getAllConfigs(preset instanceof Function ? preset() : preset));
|
|
21
21
|
const features = {
|
|
22
22
|
// Add experimental configs here...
|