ember-scoped-css 0.2.9 → 0.2.11
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/index.js +11 -15
- package/package.json +7 -2
- package/src/addon-css-rollup.js +10 -10
- package/src/addon-hbs-rollup.js +8 -8
- package/src/addon-js-unplugin.js +12 -12
- package/src/addon-rewritecss-rollup.js +6 -6
- package/src/app-css-livereload-loader.js +8 -8
- package/src/app-css-loader.js +9 -9
- package/src/app-css-unplugin.js +8 -9
- package/src/app-dependency-loader.js +3 -3
- package/src/app-js-unplugin.js +8 -8
- package/src/app-scopedcss-webpack.js +9 -9
- package/src/babel-plugin-scoped-class.js +2 -3
- package/src/findCssInJs.js +3 -3
- package/src/fsExists.js +3 -3
- package/src/generateHash.js +5 -0
- package/src/getClassesTagsFromCss.js +5 -5
- package/src/getFiles.js +3 -3
- package/src/getImportedCssFiles.js +2 -2
- package/src/getPostfix.js +5 -5
- package/src/isInsideGlobal.js +2 -2
- package/src/renameClass.js +2 -2
- package/src/replaceGlimmerAst.js +7 -12
- package/src/replaceHbsInJs.js +4 -9
- package/src/replaceScopedClass.js +5 -5
- package/src/rewriteCss.js +5 -5
- package/src/rewriteHbs.js +4 -4
- package/src/rollup-ember-template-imports-plugin.js +7 -9
- package/src/scopedClass.js +5 -5
- package/test/getClassesTagsFromCss.js +2 -2
- package/test/getPostfix.js +3 -3
- package/test/rewriteCss.js +3 -3
package/index.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const babelPluginScopedClass = require('./src/babel-plugin-scoped-class');
|
|
12
|
-
const scopedClassModule = require('./src/scopedClass');
|
|
1
|
+
import rollupEmberTemplateImportsPlugin from './src/rollup-ember-template-imports-plugin.js';
|
|
2
|
+
import addonJsUnplugin from './src/addon-js-unplugin.js';
|
|
3
|
+
import addonCssRollup from './src/addon-css-rollup.js';
|
|
4
|
+
import addonHbsRollup from './src/addon-hbs-rollup.js';
|
|
5
|
+
import appJsUnplugin from './src/app-js-unplugin.js';
|
|
6
|
+
import appCssUnplugin from './src/app-css-unplugin.js';
|
|
7
|
+
import appCssLoader from './src/app-css-loader.js';
|
|
8
|
+
import appDependencyLoader from './src/app-dependency-loader.js';
|
|
9
|
+
import appScopedcssWebpack from './src/app-scopedcss-webpack.js';
|
|
10
|
+
import addonRewritecssRollup from './src/addon-rewritecss-rollup.js';
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
export {
|
|
15
13
|
rollupEmberTemplateImportsPlugin,
|
|
16
14
|
addonJsUnplugin,
|
|
17
15
|
addonCssRollup,
|
|
@@ -22,6 +20,4 @@ module.exports = {
|
|
|
22
20
|
appDependencyLoader,
|
|
23
21
|
appScopedcssWebpack,
|
|
24
22
|
addonRewritecssRollup,
|
|
25
|
-
babelPluginScopedClass,
|
|
26
|
-
'test-helper': scopedClassModule,
|
|
27
23
|
};
|
package/package.json
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-scoped-css",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
4
4
|
"description": "",
|
|
5
|
-
"type": "
|
|
5
|
+
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.js",
|
|
9
|
+
"./babel-plugin-scoped-class": "./src/babel-plugin-scoped-class.js",
|
|
10
|
+
"./test-helper": "./src/scopedClass.js"
|
|
11
|
+
},
|
|
7
12
|
"keywords": [],
|
|
8
13
|
"author": "",
|
|
9
14
|
"license": "ISC",
|
package/src/addon-css-rollup.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import getPostfix from './getPostfix.js';
|
|
3
|
+
import rewriteCss from './rewriteCss.js';
|
|
4
|
+
import { readFile } from 'fs/promises';
|
|
5
|
+
import fsExists from './fsExists.js';
|
|
6
|
+
import findCssInJs from './findCssInJs.js';
|
|
7
|
+
import getImportedCssFiles from './getImportedCssFiles.js';
|
|
8
|
+
import recast from 'recast';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
export default function () {
|
|
11
11
|
return {
|
|
12
12
|
name: 'addon-css-rollup',
|
|
13
13
|
|
|
@@ -89,4 +89,4 @@ module.exports = function () {
|
|
|
89
89
|
}
|
|
90
90
|
},
|
|
91
91
|
};
|
|
92
|
-
}
|
|
92
|
+
}
|
package/src/addon-hbs-rollup.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { readFile } from 'fs/promises';
|
|
2
|
+
import getPostfix from './getPostfix.js';
|
|
3
|
+
import replaceHbsInJs from './replaceHbsInJs.js';
|
|
4
|
+
import getClassesTagsFromCss from './getClassesTagsFromCss.js';
|
|
5
|
+
import rewriteHbs from './rewriteHbs.js';
|
|
6
|
+
import fsExists from './fsExists.js';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
export default function rollupCssColocation(options = {}) {
|
|
9
9
|
return {
|
|
10
10
|
name: 'addon-hbs-rollup',
|
|
11
11
|
|
|
@@ -39,4 +39,4 @@ module.exports = function rollupCssColocation(options = {}) {
|
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
};
|
|
42
|
-
}
|
|
42
|
+
}
|
package/src/addon-js-unplugin.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { createUnplugin } from 'unplugin';
|
|
2
|
+
import { readFile } from 'fs/promises';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import getClassesTagsFromCss from './getClassesTagsFromCss.js';
|
|
5
|
+
import getPostfix from './getPostfix.js';
|
|
6
|
+
import replaceHbsInJs from './replaceHbsInJs.js';
|
|
7
|
+
import rewriteHbs from './rewriteHbs.js';
|
|
8
|
+
import fsExists from './fsExists.js';
|
|
9
|
+
import findCssInJs from './findCssInJs.js';
|
|
10
|
+
import recast from 'recast';
|
|
11
|
+
|
|
12
|
+
export default createUnplugin((options) => {
|
|
13
13
|
return {
|
|
14
14
|
name: 'addon-js-unplugin',
|
|
15
15
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import getPostfix from './getPostfix.js';
|
|
3
|
+
import rewriteCss from './rewriteCss.js';
|
|
4
|
+
import fsExists from './fsExists.js';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
export default function () {
|
|
7
7
|
return {
|
|
8
8
|
name: 'addon-rewritecss-rollup',
|
|
9
9
|
|
|
@@ -26,4 +26,4 @@ module.exports = function () {
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
};
|
|
29
|
-
}
|
|
29
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { createUnplugin } from 'unplugin';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { readFile, writeFile } from 'fs/promises';
|
|
4
|
+
import { Compilation } from 'webpack';
|
|
5
|
+
import getPostfix from './getPostfix.js';
|
|
6
|
+
import cheerio from 'cheerio';
|
|
7
|
+
|
|
8
|
+
export default createUnplugin(({ appDir, loaders, htmlEntrypointInfo }) => {
|
|
9
9
|
return {
|
|
10
10
|
name: 'app-css-livereload-loader',
|
|
11
11
|
|
package/src/app-css-loader.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
//
|
|
1
|
+
// import { createUnplugin } from 'unplugin';
|
|
2
|
+
import { basename, join } from 'path';
|
|
3
|
+
import fsExists from './fsExists.js';
|
|
4
|
+
import getPostfix from './getPostfix.js';
|
|
5
|
+
import rewriteCss from './rewriteCss.js';
|
|
6
|
+
// import path from 'path';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
export default async function (code) {
|
|
9
9
|
const cssPath = this.resourcePath;
|
|
10
10
|
const cssFileName = basename(cssPath);
|
|
11
11
|
const postfix = getPostfix(cssPath);
|
|
@@ -18,11 +18,11 @@ module.exports = async function (code) {
|
|
|
18
18
|
]);
|
|
19
19
|
|
|
20
20
|
let rewrittenCss;
|
|
21
|
-
if (hbsExists || gjsExists && cssPath.startsWith(this.rootContext)) {
|
|
21
|
+
if (hbsExists || (gjsExists && cssPath.startsWith(this.rootContext))) {
|
|
22
22
|
rewrittenCss = rewriteCss(code, postfix, cssFileName);
|
|
23
23
|
} else {
|
|
24
24
|
rewrittenCss = code;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
return rewrittenCss;
|
|
28
|
-
}
|
|
28
|
+
}
|
package/src/app-css-unplugin.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { createUnplugin } from 'unplugin';
|
|
2
|
+
import replaceGlimmerAst from './replaceGlimmerAst.js';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import getPostfix from './getPostfix.js';
|
|
5
|
+
import getClassesTagsFromCss from './getClassesTagsFromCss.js';
|
|
6
|
+
import { readFile } from 'fs/promises';
|
|
7
|
+
import fsExists from './fsExists.js';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
module.exports = createUnplugin(() => {
|
|
9
|
+
export default createUnplugin(() => {
|
|
11
10
|
return {
|
|
12
11
|
name: 'app-css-unplugin',
|
|
13
12
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import fsExists from './fsExists.js';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export default async function (source) {
|
|
4
4
|
if (this.resourcePath.endsWith('.js')) {
|
|
5
5
|
const hbsExists = await fsExists(this.resourcePath.replace(/\.js/, '.hbs'));
|
|
6
6
|
if (hbsExists) {
|
|
@@ -16,4 +16,4 @@ module.exports = async function (source) {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
return source;
|
|
19
|
-
}
|
|
19
|
+
}
|
package/src/app-js-unplugin.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { createUnplugin } from 'unplugin';
|
|
2
|
+
import replaceGlimmerAst from './replaceGlimmerAst.js';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import getPostfix from './getPostfix.js';
|
|
5
|
+
import getClassesTagsFromCss from './getClassesTagsFromCss.js';
|
|
6
|
+
import { readFile } from 'fs/promises';
|
|
7
|
+
import fsExists from './fsExists.js';
|
|
8
8
|
|
|
9
9
|
function* iterateOpcodes(opcodes) {
|
|
10
10
|
for (let instruction of opcodes) {
|
|
@@ -37,7 +37,7 @@ function inflateTagName(tag) {
|
|
|
37
37
|
throw new Error('Unknown tag');
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
export default createUnplugin(({ appDir }) => {
|
|
41
41
|
return {
|
|
42
42
|
name: 'app-js-unplugin',
|
|
43
43
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
// import { RawSource } from 'webpack-sources';
|
|
2
|
+
import rewriteCss from './rewriteCss.js';
|
|
3
|
+
import { readFile, writeFile } from 'fs/promises';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import getPostfix from './getPostfix.js';
|
|
6
|
+
import fsExists from './fsExists.js';
|
|
7
|
+
import getFiles from './getFiles.js';
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
export default class {
|
|
10
10
|
apply(compiler) {
|
|
11
11
|
if (process.env.EMBER_ENV === 'production') {
|
|
12
12
|
return;
|
|
@@ -65,4 +65,4 @@ module.exports = class {
|
|
|
65
65
|
}
|
|
66
66
|
);
|
|
67
67
|
}
|
|
68
|
-
}
|
|
68
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
const replaceScopedClass = require('./replaceScopedClass');
|
|
1
|
+
import replaceScopedClass from './replaceScopedClass.js';
|
|
3
2
|
|
|
4
3
|
const scopedClass = () => {
|
|
5
4
|
return {
|
|
@@ -27,4 +26,4 @@ const scopedClass = () => {
|
|
|
27
26
|
};
|
|
28
27
|
};
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
export default scopedClass;
|
package/src/findCssInJs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import recast from 'recast';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export default function (script, removeCallExpression = false) {
|
|
4
4
|
const ast = typeof script === 'string' ? recast.parse(script) : script;
|
|
5
5
|
let css = '';
|
|
6
6
|
|
|
@@ -24,4 +24,4 @@ module.exports = function (script, removeCallExpression = false) {
|
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
return { css, ast };
|
|
27
|
-
}
|
|
27
|
+
}
|
package/src/fsExists.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { stat } from 'fs/promises';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export default async function (path) {
|
|
4
4
|
try {
|
|
5
5
|
await stat(path);
|
|
6
6
|
return true;
|
|
7
7
|
} catch (e) {
|
|
8
8
|
return false;
|
|
9
9
|
}
|
|
10
|
-
}
|
|
10
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import postcss from 'postcss';
|
|
2
|
+
import parser from 'postcss-selector-parser';
|
|
3
|
+
import isInsideGlobal from './isInsideGlobal.js';
|
|
4
4
|
|
|
5
5
|
function getClassesAndTags(sel, classes, tags) {
|
|
6
6
|
const transform = (sls) => {
|
|
@@ -16,7 +16,7 @@ function getClassesAndTags(sel, classes, tags) {
|
|
|
16
16
|
parser(transform).processSync(sel);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
export default function getClassesTagsFromCss(css) {
|
|
20
20
|
const classes = new Set();
|
|
21
21
|
const tags = new Set();
|
|
22
22
|
|
|
@@ -28,4 +28,4 @@ module.exports = function getClassesTagsFromCss(css) {
|
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
return { classes, tags };
|
|
31
|
-
}
|
|
31
|
+
}
|
package/src/getFiles.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import glob from 'glob';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export default function (globPath) {
|
|
4
4
|
return new Promise((resolve, reject) => {
|
|
5
5
|
glob(globPath, (err, files) => {
|
|
6
6
|
if (err) {
|
|
@@ -9,4 +9,4 @@ module.exports = function (globPath) {
|
|
|
9
9
|
resolve(files);
|
|
10
10
|
});
|
|
11
11
|
});
|
|
12
|
-
}
|
|
12
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export default function (css) {
|
|
2
2
|
const regex = /@import\s+["']?([^"')]+)["']?;/g;
|
|
3
3
|
const importedCssPaths = [];
|
|
4
4
|
let match;
|
|
@@ -15,4 +15,4 @@ module.exports = function (css) {
|
|
|
15
15
|
css,
|
|
16
16
|
importedCssPaths,
|
|
17
17
|
};
|
|
18
|
-
}
|
|
18
|
+
}
|
package/src/getPostfix.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import generateHash from './generateHash.js';
|
|
2
|
+
import path from 'path';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export default function (cssFileName) {
|
|
5
5
|
const relativePath = path.relative(process.cwd(), cssFileName);
|
|
6
|
-
return
|
|
7
|
-
}
|
|
6
|
+
return generateHash(relativePath);
|
|
7
|
+
}
|
package/src/isInsideGlobal.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
export default function isInsideGlobal(node, func) {
|
|
2
2
|
const parent = node.parent;
|
|
3
3
|
if (!parent) return false;
|
|
4
4
|
if (parent.type === 'pseudo' && parent.value === ':global') return true;
|
|
5
5
|
return isInsideGlobal(parent, func);
|
|
6
|
-
}
|
|
6
|
+
}
|
package/src/renameClass.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export default function (className, postfix, classesInCss) {
|
|
2
2
|
const classes = className.split(/\s+/);
|
|
3
3
|
const renamedClasses = classes
|
|
4
4
|
.filter((c) => c)
|
|
@@ -11,4 +11,4 @@ module.exports = function (className, postfix, classesInCss) {
|
|
|
11
11
|
renamedClasses
|
|
12
12
|
);
|
|
13
13
|
return renamedWithPreservedSpaces;
|
|
14
|
-
}
|
|
14
|
+
}
|
package/src/replaceGlimmerAst.js
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const fsExists = require('./fsExists');
|
|
1
|
+
import recast from 'recast';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { readFile } from 'fs/promises';
|
|
4
|
+
import fsExists from './fsExists.js';
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
module.exports = async function (script, id, replaceFunction) {
|
|
12
|
-
const ast = recast.parse(script, parseOptions);
|
|
6
|
+
export default async function (script, id, replaceFunction) {
|
|
7
|
+
const ast = recast.parse(script);
|
|
13
8
|
const cssPath = id.replace(/(\.js)|(\.hbs)/, '.css');
|
|
14
9
|
let css;
|
|
15
10
|
|
|
@@ -53,4 +48,4 @@ module.exports = async function (script, id, replaceFunction) {
|
|
|
53
48
|
});
|
|
54
49
|
const resultScript = recast.print(ast).code;
|
|
55
50
|
return resultScript;
|
|
56
|
-
}
|
|
51
|
+
}
|
package/src/replaceHbsInJs.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
const babelParser = require('recast/parsers/babel');
|
|
1
|
+
import recast from 'recast';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
module.exports = function (script, replaceFunction) {
|
|
9
|
-
const ast = recast.parse(script, parseOptions);
|
|
3
|
+
export default function (script, replaceFunction) {
|
|
4
|
+
const ast = recast.parse(script);
|
|
10
5
|
recast.visit(ast, {
|
|
11
6
|
visitCallExpression(path) {
|
|
12
7
|
const node = path.node;
|
|
@@ -29,4 +24,4 @@ module.exports = function (script, replaceFunction) {
|
|
|
29
24
|
},
|
|
30
25
|
});
|
|
31
26
|
return recast.print(ast).code;
|
|
32
|
-
}
|
|
27
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import recast from 'ember-template-recast';
|
|
2
|
+
import renameClass from './renameClass.js';
|
|
3
|
+
import getPostfix from './getPostfix.js';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
export default function (hbs, templatePath, basePath) {
|
|
6
6
|
let ast = recast.parse(hbs);
|
|
7
7
|
let stack = [];
|
|
8
8
|
const cssPath = templatePath.replace(/(\.hbs)?\.js$/, '.css');
|
|
@@ -63,4 +63,4 @@ module.exports = function (hbs, templatePath, basePath) {
|
|
|
63
63
|
|
|
64
64
|
let result = recast.print(ast);
|
|
65
65
|
return result;
|
|
66
|
-
}
|
|
66
|
+
}
|
package/src/rewriteCss.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import parser from 'postcss-selector-parser';
|
|
2
|
+
import postcss from 'postcss';
|
|
3
|
+
import isInsideGlobal from './isInsideGlobal.js';
|
|
4
4
|
|
|
5
5
|
function rewriteSelector(sel, postfix) {
|
|
6
6
|
const transform = (selectors) => {
|
|
@@ -33,7 +33,7 @@ function isInsideKeyframes(node) {
|
|
|
33
33
|
return isInsideKeyframes(parent);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
export default function rewriteCss(css, postfix, fileName) {
|
|
37
37
|
const ast = postcss.parse(css);
|
|
38
38
|
ast.walk((node) => {
|
|
39
39
|
if (node.type === 'rule' && !isInsideKeyframes(node)) {
|
|
@@ -44,4 +44,4 @@ module.exports = function rewriteCss(css, postfix, fileName) {
|
|
|
44
44
|
const rewrittenCss = ast.toString();
|
|
45
45
|
return `/* ${fileName} */\n@layer components {\n\n` + rewrittenCss + '\n}\n';
|
|
46
46
|
// return `/* ${fileName} */\n ${rewrittenCss}`;
|
|
47
|
-
}
|
|
47
|
+
}
|
package/src/rewriteHbs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import recast from 'ember-template-recast';
|
|
2
|
+
import renameClass from './renameClass.js';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export default function rewriteHbs(hbs, classes, tags, postfix) {
|
|
5
5
|
let ast = recast.parse(hbs);
|
|
6
6
|
|
|
7
7
|
recast.traverse(ast, {
|
|
@@ -39,4 +39,4 @@ module.exports = function rewriteHbs(hbs, classes, tags, postfix) {
|
|
|
39
39
|
|
|
40
40
|
let result = recast.print(ast);
|
|
41
41
|
return result;
|
|
42
|
-
}
|
|
42
|
+
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} = require('ember-template-imports/lib/preprocess-embedded-templates.js');
|
|
6
|
-
const {
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { preprocessEmbeddedTemplates } from 'ember-template-imports/lib/preprocess-embedded-templates.js';
|
|
4
|
+
import {
|
|
7
5
|
TEMPLATE_TAG_NAME,
|
|
8
6
|
TEMPLATE_TAG_PLACEHOLDER,
|
|
9
|
-
}
|
|
7
|
+
} from 'ember-template-imports/lib/util.js';
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
export default function firstClassComponentTemplates() {
|
|
12
10
|
return {
|
|
13
11
|
name: 'preprocess-fccts',
|
|
14
12
|
async resolveId(source, importer, options) {
|
|
@@ -42,7 +40,7 @@ module.exports = function firstClassComponentTemplates() {
|
|
|
42
40
|
}
|
|
43
41
|
},
|
|
44
42
|
};
|
|
45
|
-
}
|
|
43
|
+
}
|
|
46
44
|
|
|
47
45
|
const FCCT_EXTENSION = /\.g([jt]s)$/;
|
|
48
46
|
|
package/src/scopedClass.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import generateHash from './generateHash.js';
|
|
2
|
+
import renameClass from './renameClass.js';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
return renameClass(className,
|
|
6
|
-
}
|
|
4
|
+
export function scopedClass(className, relativeCssPath) {
|
|
5
|
+
return renameClass(className, generateHash(relativeCssPath));
|
|
6
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import getClassesTagsFromCss from '../src/getClassesTagsFromCss.js';
|
|
3
3
|
|
|
4
4
|
describe('rewriteCss', function () {
|
|
5
5
|
it('should return classes and tags that are not in :global', function () {
|
package/test/getPostfix.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { stub } from 'sinon';
|
|
3
|
+
import getPostfix from '../src/getPostfix.js';
|
|
4
4
|
|
|
5
5
|
describe('getPostfix', function () {
|
|
6
6
|
it('should return a string', function () {
|
package/test/rewriteCss.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { stub } from 'sinon';
|
|
3
|
+
import rewriteCss from '../src/rewriteCss.js';
|
|
4
4
|
|
|
5
5
|
describe('rewriteCss', function () {
|
|
6
6
|
it('should rewrite css', function () {
|