ember-scoped-css 2.0.3 → 2.1.0
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/dist/cjs/all-Bimr-GZ4.cjs +1319 -0
- package/dist/cjs/all.cjs +1 -1
- package/dist/cjs/babel.cjs +1 -1
- package/dist/cjs/rollup.cjs +1 -1
- package/dist/cjs/vite.cjs +1 -1
- package/package.json +1 -1
- package/src/build/babel-plugin.js +42 -1
- package/src/build/unplugin-colocated.js +2 -5
- package/src/lib/path/const.js +1 -0
- package/src/lib/path/utils.isRelevantFile.test.ts +7 -0
- package/src/lib/path/utils.js +1 -0
- package/dist/cjs/all-CfBAmXua.cjs +0 -1308
package/dist/cjs/all.cjs
CHANGED
package/dist/cjs/babel.cjs
CHANGED
package/dist/cjs/rollup.cjs
CHANGED
package/dist/cjs/vite.cjs
CHANGED
package/package.json
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
appPath,
|
|
3
|
+
hashFromModulePath,
|
|
4
|
+
isRelevantFile,
|
|
5
|
+
} from '../lib/path/utils.js';
|
|
6
|
+
import { renameClass } from '../lib/renameClass.js';
|
|
2
7
|
|
|
3
8
|
function _isRelevantFile(state, cwd) {
|
|
4
9
|
let fileName = state.file.opts.filename;
|
|
@@ -34,6 +39,10 @@ export const scopedCSS = (config) => (env, options, workingDirectory) => {
|
|
|
34
39
|
|
|
35
40
|
return;
|
|
36
41
|
}
|
|
42
|
+
|
|
43
|
+
let modulePath = appPath(state.filename);
|
|
44
|
+
|
|
45
|
+
state.postfix = hashFromModulePath(modulePath);
|
|
37
46
|
},
|
|
38
47
|
},
|
|
39
48
|
ImportDeclaration(path, state) {
|
|
@@ -59,6 +68,38 @@ export const scopedCSS = (config) => (env, options, workingDirectory) => {
|
|
|
59
68
|
path.remove();
|
|
60
69
|
}
|
|
61
70
|
},
|
|
71
|
+
/**
|
|
72
|
+
* Rename usages in JS/TS/GJS/GTS
|
|
73
|
+
*/
|
|
74
|
+
CallExpression(path, state) {
|
|
75
|
+
if (state.canSkip) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (
|
|
80
|
+
path.node.callee.type === 'Identifier' &&
|
|
81
|
+
path.node.callee.name === state.file.opts?.importedScopedClass
|
|
82
|
+
) {
|
|
83
|
+
if (
|
|
84
|
+
path.node.arguments.length !== 1 ||
|
|
85
|
+
path.node.arguments[0].type !== 'StringLiteral'
|
|
86
|
+
) {
|
|
87
|
+
throw new Error(
|
|
88
|
+
`The scopedClass helper only accepts a single, non-dynamic, string literal argument.`,
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const original = path.node.arguments[0].value;
|
|
93
|
+
const renamed = renameClass(
|
|
94
|
+
original,
|
|
95
|
+
state.postfix,
|
|
96
|
+
new Set([original]),
|
|
97
|
+
);
|
|
98
|
+
const transformedString = env.types.stringLiteral(renamed);
|
|
99
|
+
|
|
100
|
+
path.replaceWith(transformedString);
|
|
101
|
+
}
|
|
102
|
+
},
|
|
62
103
|
/**
|
|
63
104
|
* Only in strict mode, do we care about remoning the scope bag reference
|
|
64
105
|
*/
|
|
@@ -51,11 +51,6 @@ export function colocated(options = {}) {
|
|
|
51
51
|
path.basename(parsed.fileName),
|
|
52
52
|
);
|
|
53
53
|
|
|
54
|
-
/**
|
|
55
|
-
* Rollup doesn't normally watch CSS files
|
|
56
|
-
*/
|
|
57
|
-
this.addWatchFile(filePath);
|
|
58
|
-
|
|
59
54
|
return buildResponse(id, filePath);
|
|
60
55
|
}
|
|
61
56
|
},
|
|
@@ -63,6 +58,8 @@ export function colocated(options = {}) {
|
|
|
63
58
|
const meta = this.getModuleInfo(id)?.meta?.[META];
|
|
64
59
|
|
|
65
60
|
if (meta) {
|
|
61
|
+
this.addWatchFile(meta.fullPath);
|
|
62
|
+
|
|
66
63
|
let code = readFileSync(meta.fullPath, 'utf-8');
|
|
67
64
|
|
|
68
65
|
let css = rewriteCss(
|
package/src/lib/path/const.js
CHANGED
|
@@ -9,6 +9,7 @@ export const leadingSlashPath = {
|
|
|
9
9
|
atEmbroider: path.join('/@embroider'),
|
|
10
10
|
componentsDir: path.join('/components/'),
|
|
11
11
|
templatesDir: path.join('/templates/'),
|
|
12
|
+
routesDir: path.join('/routes/'),
|
|
12
13
|
testem: path.join('/testem'),
|
|
13
14
|
src: path.join('/src/'),
|
|
14
15
|
app: path.join('/app/'),
|
|
@@ -20,6 +20,13 @@ describe('isRelevantFile()', () => {
|
|
|
20
20
|
|
|
21
21
|
expect(result).toBeTruthy();
|
|
22
22
|
});
|
|
23
|
+
|
|
24
|
+
it('for /routes/', () => {
|
|
25
|
+
let file = path.join(paths.viteApp, 'app/routes/application.gts');
|
|
26
|
+
let result = isRelevantFile(file, { cwd: paths.viteApp });
|
|
27
|
+
|
|
28
|
+
expect(result).toBeTruthy();
|
|
29
|
+
});
|
|
23
30
|
});
|
|
24
31
|
|
|
25
32
|
describe('the file is not relevant', () => {
|
package/src/lib/path/utils.js
CHANGED