babel-preset-startupjs 0.60.0-canary.2 → 0.60.0-canary.7

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/index.js +17 -2
  2. package/package.json +5 -5
package/index.js CHANGED
@@ -45,6 +45,8 @@ module.exports = (api, {
45
45
  platform,
46
46
  reactType,
47
47
  cache,
48
+ compileCssImports,
49
+ cssFileExtensions,
48
50
  transformCss = true,
49
51
  transformPug = true,
50
52
  useRequireContext = true,
@@ -52,6 +54,18 @@ module.exports = (api, {
52
54
  envs = ['features', 'isomorphic', 'client'],
53
55
  isStartupjsFile = createStartupjsFileChecker({ clientOnly })
54
56
  } = {}) => {
57
+ const isMetro = api.caller(caller => caller?.name === 'metro')
58
+
59
+ // By default on Metro we don't need to compile CSS imports since we are relying on the custom
60
+ // StartupJS metro-babel-transformer which handles CSS imports as separate files.
61
+ if (compileCssImports == null && isMetro) compileCssImports = false
62
+
63
+ // on Metro we transform any CSS imports since StartupJS metro-babel-transformer
64
+ // turns off Expo's default CSS support and handles only our CSS imports.
65
+ // When used in a plain Web project though though,
66
+ // we want to only handle the default ['cssx.css', 'cssx.styl'] extensions.
67
+ if (cssFileExtensions == null && isMetro) cssFileExtensions = ['styl', 'css']
68
+
55
69
  return {
56
70
  overrides: [{
57
71
  test: isJsxSource,
@@ -85,10 +99,11 @@ module.exports = (api, {
85
99
  }],
86
100
  // CSS modules (separate .styl/.css file)
87
101
  transformCss && [require('cssxjs/babel/plugin-rn-stylename-to-style'), {
88
- extensions: ['styl', 'css'],
102
+ extensions: cssFileExtensions,
89
103
  useImport: true,
90
104
  reactType,
91
- cache
105
+ cache,
106
+ compileCssImports
92
107
  }],
93
108
 
94
109
  // auto-load startupjs plugins
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-preset-startupjs",
3
- "version": "0.60.0-canary.2",
3
+ "version": "0.60.0-canary.7",
4
4
  "description": "Babel preset for compiling StartupJS app on server, web, native",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -15,9 +15,9 @@
15
15
  "@babel/core": "^7.9.0",
16
16
  "@babel/plugin-syntax-jsx": "^7.0.0",
17
17
  "@babel/plugin-syntax-typescript": "^7.23.3",
18
- "@startupjs/babel-plugin-i18n-extract": "^0.60.0-canary.0",
19
- "@startupjs/babel-plugin-startupjs": "^0.60.0-canary.0",
20
- "@startupjs/babel-plugin-startupjs-debug": "^0.60.0-canary.2"
18
+ "@startupjs/babel-plugin-i18n-extract": "^0.60.0-canary.7",
19
+ "@startupjs/babel-plugin-startupjs": "^0.60.0-canary.7",
20
+ "@startupjs/babel-plugin-startupjs-debug": "^0.60.0-canary.7"
21
21
  },
22
- "gitHead": "cbea3f3fe0689dfca50dcf5ddf9ef67730a680e2"
22
+ "gitHead": "68c5c8e9757e263133c36a24f46ba35efc9b87b8"
23
23
  }