@react-spectrum/parcel-namer-s2 0.3.2 → 1.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.
Files changed (2) hide show
  1. package/S2Namer.js +46 -22
  2. package/package.json +3 -3
package/S2Namer.js CHANGED
@@ -17,31 +17,55 @@ module.exports = new Namer({
17
17
  name({bundle}) {
18
18
  let mainAsset = bundle.getMainEntry();
19
19
 
20
- if (mainAsset?.filePath.includes('@react-spectrum/s2') || !mainAsset?.filePath.includes('react-spectrum/packages')) {
21
- if (bundle.needsStableName && bundle.target.distEntry) {
22
- return bundle.target.distEntry;
23
- }
24
- let ext = '.' + bundle.type;
25
- if (bundle.type === 'js') {
26
- ext = bundle.env.outputFormat === 'esmodule' ? '.mjs' : '.cjs';
20
+ if (bundle.needsStableName && bundle.target.distEntry) {
21
+ return bundle.target.distEntry;
22
+ }
23
+ let ext = '.' + bundle.type;
24
+ if (bundle.type === 'js' && bundle.target.name !== 'legacy-module' && bundle.target.name !== 'module') {
25
+ ext = bundle.env.outputFormat === 'esmodule' ? '.mjs' : '.cjs';
26
+ }
27
+ let originalExt = path.extname(mainAsset.filePath);
28
+ let basename = path.basename(mainAsset.filePath, originalExt).replace(/\*/g, 'intlStrings');
29
+ let name = basename;
30
+ let m = mainAsset.filePath.match(/spectrum-illustrations\/(linear|gradient\/generic\d)/);
31
+ if (m) {
32
+ if (originalExt === '.svg') {
33
+ return m[1] + '/internal/' + name + ext;
27
34
  }
28
- let originalExt = path.extname(mainAsset.filePath);
29
- let name = path.basename(mainAsset.filePath, originalExt).replace(/\*/g, 'intlStrings');
30
- let m = mainAsset.filePath.match(/spectrum-illustrations\/(linear|gradient\/generic\d)/);
31
- if (m) {
32
- if (originalExt === '.svg') {
33
- return m[1] + '/internal/' + name + ext;
35
+ return m[1] + '/' + name + ext;
36
+ } else if (mainAsset.filePath.includes('/exports/')) {
37
+ let index = mainAsset.filePath.indexOf('/exports/');
38
+ name = path.dirname(mainAsset.filePath.slice(index + 1)) + '/' + name;
39
+ } else if (bundle.target.distDir.endsWith('/dist') && !bundle.target.distDir.includes('/style/')) {
40
+ let index = mainAsset.filePath.indexOf('/src/');
41
+ if (index >= 0) {
42
+ name = 'private/' + path.dirname(mainAsset.filePath.slice(index + 5)) + '/' + name;
43
+ } else {
44
+ index = mainAsset.filePath.indexOf('/intl/');
45
+ if (index >= 0) {
46
+ name = 'private/' + path.dirname(mainAsset.filePath.slice(index)) + '/' + name;
47
+ } else {
48
+ name = 'private/' + name;
34
49
  }
35
- return m[1] + '/' + name + ext;
36
50
  }
37
- return name
38
- .replace(/^S2_Icon_(.*?)(Size\d+)?_\d+(?:x\d+)?_N$/, '$1')
39
- .replace(/^S2_(fill|lin)_(.+)_(generic\d)_(\d+)$/, (m, type, name, style) => {
40
- name = name[0].toUpperCase() + name.slice(1).replace(/_/g, '');
41
- return 'gradient/' + style + '/' + name;
42
- })
43
- .replace(/\.module$/, '_module')
44
- + ext;
45
51
  }
52
+
53
+ if (mainAsset.filePath.includes('@adobe/spectrum-css-temp')) {
54
+ name = 'private/' + mainAsset.filePath.split(path.sep).at(-2) + '_' + basename;
55
+ }
56
+ if (path.extname(mainAsset.filePath) === '.css' && mainAsset.type === 'js') {
57
+ // CSS module
58
+ name += '_css';
59
+ }
60
+
61
+ return name
62
+ .replace(/^S2_Icon_(.*?)(Size\d+)?_\d+(?:x\d+)?_N$/, '$1')
63
+ .replace(/^S2_(fill|lin)_(.+)_(generic\d)_(\d+)$/, (m, type, name, style) => {
64
+ name = name[0].toUpperCase() + name.slice(1).replace(/_/g, '');
65
+ return 'gradient/' + style + '/' + name;
66
+ })
67
+ .replace(/\.module$/, '_module')
68
+ + ext;
69
+ // }
46
70
  }
47
71
  });
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@react-spectrum/parcel-namer-s2",
3
- "version": "0.3.2",
3
+ "version": "1.1.0",
4
4
  "main": "S2Namer.js",
5
5
  "engines": {
6
6
  "parcel": "^2.0.0"
7
7
  },
8
8
  "dependencies": {
9
- "@parcel/plugin": "^2.16.0"
9
+ "@parcel/plugin": "^2.16.3"
10
10
  },
11
11
  "rsp": {
12
12
  "type": "cli"
@@ -19,5 +19,5 @@
19
19
  "publishConfig": {
20
20
  "access": "public"
21
21
  },
22
- "gitHead": "0bda51183baa23306342af32a82012ea0fe0f2dc"
22
+ "gitHead": "a6999bdf494a2e9c0381a5881908328bdd22ddae"
23
23
  }