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