@startupjs/bundler 0.56.0-alpha.1 → 0.56.0-alpha.10

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.
@@ -2,7 +2,7 @@
2
2
  const babel = require('@babel/core')
3
3
  const { isStartupjsPluginEcosystemFile, CONFIG_FILENAME_REGEX } = require('./utils')
4
4
 
5
- const PLUGIN_KEYS = ['name', 'for']
5
+ const PLUGIN_KEYS = ['name', 'for', 'order', 'enabled']
6
6
  const PROJECT_KEYS = ['plugins', 'modules']
7
7
  const ALL_ENVS = ['client', 'isomorphic', 'server', 'build']
8
8
  const MAGIC_IMPORTS = ['startupjs/registry', '@startupjs/registry']
@@ -28,7 +28,7 @@ module.exports = function eliminatorLoader (source) {
28
28
  require('@babel/plugin-syntax-jsx'),
29
29
  // transform pug to jsx. This generates a bunch of new AST nodes
30
30
  // (it's important to do this first before any dead code elimination runs)
31
- [require('babel-plugin-transform-react-pug'), {
31
+ [require('@startupjs/babel-plugin-transform-react-pug'), {
32
32
  classAttribute: 'styleName'
33
33
  }],
34
34
  // support calling sub-components in pug (like <Modal.Header />)
@@ -3,15 +3,12 @@
3
3
  const platformSingleton = require(
4
4
  '@startupjs/babel-plugin-rn-stylename-inline/platformSingleton'
5
5
  )
6
- const fs = require('fs')
7
- const path = require('path')
6
+ const { existsSync } = require('fs')
7
+ const { join } = require('path')
8
8
  const stylus = require('stylus')
9
- const STYLES_PATH = path.join(process.cwd(), 'styles/index.styl')
10
9
 
10
+ const PROJECT_STYLES_PATH = join(process.cwd(), 'styles/index.styl')
11
11
  let UI_STYLES_PATH
12
- try {
13
- UI_STYLES_PATH = require.resolve('@startupjs/ui/styles/index.styl')
14
- } catch (err) {}
15
12
 
16
13
  function renderToCSS (src, filename) {
17
14
  let compiled
@@ -24,13 +21,13 @@ function renderToCSS (src, filename) {
24
21
  compiler.define(`__${platform.toUpperCase()}__`, true)
25
22
  }
26
23
 
27
- if (fs.existsSync(UI_STYLES_PATH)) {
24
+ if (checkUiStylesExist()) {
28
25
  compiler.import(UI_STYLES_PATH)
29
26
  }
30
27
 
31
28
  // TODO: Make this a setting
32
- if (fs.existsSync(STYLES_PATH)) {
33
- compiler.import(STYLES_PATH)
29
+ if (checkProjectStylesExist()) {
30
+ compiler.import(PROJECT_STYLES_PATH)
34
31
  }
35
32
 
36
33
  compiler.render(function (err, res) {
@@ -46,3 +43,28 @@ function renderToCSS (src, filename) {
46
43
  module.exports = function stylusToReactNative (source) {
47
44
  return renderToCSS(source, this.resourcePath)
48
45
  }
46
+
47
+ // check if @startupjs/ui is being used to load styles file from it, cache result for 5 seconds
48
+ let uiStylesExist
49
+ let uiStylesLastChecked = 0
50
+ function checkUiStylesExist () {
51
+ if (uiStylesLastChecked + 5000 > Date.now()) return uiStylesExist
52
+ uiStylesLastChecked = Date.now()
53
+ try {
54
+ UI_STYLES_PATH = join(require.resolve('@startupjs/ui'), '../styles/index.styl')
55
+ uiStylesExist = existsSync(UI_STYLES_PATH)
56
+ } catch {
57
+ uiStylesExist = false
58
+ }
59
+ return uiStylesExist
60
+ }
61
+
62
+ // check if project styles file exist, cache result for 5 seconds
63
+ let projectStylesExist
64
+ let projectStylesLastChecked = 0
65
+ function checkProjectStylesExist () {
66
+ if (projectStylesLastChecked + 5000 > Date.now()) return projectStylesExist
67
+ projectStylesLastChecked = Date.now()
68
+ projectStylesExist = existsSync(PROJECT_STYLES_PATH)
69
+ return projectStylesExist
70
+ }
package/metro-config.js CHANGED
@@ -9,7 +9,8 @@ exports.getDefaultConfig = function getDefaultConfig (projectRoot, { upstreamCon
9
9
  ...upstreamConfig,
10
10
  transformer: {
11
11
  ...upstreamConfig.transformer,
12
- babelTransformerPath: require.resolve('./metro-babel-transformer.js')
12
+ babelTransformerPath: require.resolve('./metro-babel-transformer.js'),
13
+ unstable_allowRequireContext: true
13
14
  },
14
15
  resolver: {
15
16
  ...upstreamConfig.resolver,
@@ -18,7 +19,8 @@ exports.getDefaultConfig = function getDefaultConfig (projectRoot, { upstreamCon
18
19
  ...(isExpo ? ['expo.ts', 'expo.tsx', 'expo.js', 'expo.jsx', 'expo.mjs', 'expo.cjs'] : []),
19
20
  ...(upstreamConfig.resolver.sourceExts || []),
20
21
  ...['mjs', 'cjs', 'md', 'mdx', 'css', 'styl', 'svg']
21
- ]))
22
+ ])),
23
+ unstable_enablePackageExports: true
22
24
  },
23
25
  server: {
24
26
  ...upstreamConfig.server,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startupjs/bundler",
3
- "version": "0.56.0-alpha.1",
3
+ "version": "0.56.0-alpha.10",
4
4
  "description": "Opinionated scripts and configs to develop a react-native-web project",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -24,11 +24,12 @@
24
24
  "@startupjs/babel-plugin-eliminator": "^0.56.0-alpha.1",
25
25
  "@startupjs/babel-plugin-react-css-modules": "^6.5.4-1",
26
26
  "@startupjs/babel-plugin-react-pug-classnames": "^0.56.0-alpha.0",
27
- "@startupjs/babel-plugin-startupjs-plugins": "^0.56.0-alpha.1",
27
+ "@startupjs/babel-plugin-startupjs-plugins": "^0.56.0-alpha.10",
28
+ "@startupjs/babel-plugin-transform-react-pug": "^7.0.1-0",
28
29
  "@startupjs/css-to-react-native-transform": "^1.9.0-2",
29
30
  "@startupjs/plugin": "^0.56.0-alpha.0",
30
- "@startupjs/registry": "^0.56.0-alpha.1",
31
- "@startupjs/server": "^0.56.0-alpha.1",
31
+ "@startupjs/registry": "^0.56.0-alpha.10",
32
+ "@startupjs/server": "^0.56.0-alpha.10",
32
33
  "@svgr/core": "^8.1.0",
33
34
  "@svgr/plugin-jsx": "^8.1.0",
34
35
  "@svgr/plugin-svgo": "^8.1.0",
@@ -36,8 +37,7 @@
36
37
  "assets-webpack-plugin": "^7.1.1",
37
38
  "autoprefixer": "^10.4.0",
38
39
  "babel-loader": "^8.2.3",
39
- "babel-plugin-transform-react-pug": "^7.0.1",
40
- "babel-preset-startupjs": "^0.56.0-alpha.1",
40
+ "babel-preset-startupjs": "^0.56.0-alpha.10",
41
41
  "connect": "^3.7.0",
42
42
  "css-loader": "^6.5.0",
43
43
  "css-minimizer-webpack-plugin": "^5.0.0",
@@ -61,5 +61,5 @@
61
61
  "peerDependencies": {
62
62
  "react-native-svg": "*"
63
63
  },
64
- "gitHead": "30b858bb3203dc9dc064a3b16e060e2cc1777a71"
64
+ "gitHead": "5abdbdd3f265579cd7c5485a30441d54001cd26e"
65
65
  }