@startupjs/bundler 0.56.0-alpha.2 → 0.56.0-alpha.25

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,9 +2,9 @@
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
- const ALL_ENVS = ['client', 'isomorphic', 'server', 'build']
7
+ const ALL_ENVS = ['features', 'isomorphic', 'client', 'server', 'build']
8
8
  const MAGIC_IMPORTS = ['startupjs/registry', '@startupjs/registry']
9
9
 
10
10
  module.exports = function eliminatorLoader (source) {
@@ -14,7 +14,7 @@ module.exports = function eliminatorLoader (source) {
14
14
  if (!(isStartupjsPluginEcosystemFile(filename))) return source
15
15
 
16
16
  const envs = this.query.envs
17
- if (!envs) throw Error("eliminatorLoader: envs not provided (for example ['client', 'isomorphic'])")
17
+ if (!envs) throw Error("eliminatorLoader: envs not provided (for example ['features', 'isomorphic', 'client'])")
18
18
 
19
19
  let code = source
20
20
 
@@ -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 />)
@@ -32,7 +32,7 @@ module.exports.transform = async function startupjsMetroBabelTransform ({
32
32
 
33
33
  // js transformations
34
34
  if (/\.[mc]?[jt]sx?$/.test(filename)) {
35
- src = callLoader(eliminatorLoader, src, filename, { envs: ['client', 'isomorphic'] })
35
+ src = callLoader(eliminatorLoader, src, filename, { envs: ['features', 'isomorphic', 'client'] })
36
36
  }
37
37
  if ((/\.mdx?$/.test(filename) || /\.[mc]?[jt]sx?$/.test(filename)) && /['"](?:startupjs|@env)['"]/.test(src)) {
38
38
  src = callLoader(startupjsLoader, src, filename, { platform })
package/metro-config.js CHANGED
@@ -1,15 +1,18 @@
1
+ const { getFeatures } = require('@startupjs/babel-plugin-startupjs-plugins/loader')
1
2
  const connect = require('connect')
2
3
 
3
4
  // To pass existing config for modification, pass it as 'upstreamConfig' in options:
4
5
  // config = getDefaultConfig(__dirname, { upstreamConfig })
5
6
  exports.getDefaultConfig = function getDefaultConfig (projectRoot, { upstreamConfig } = {}) {
7
+ const features = getFeatures(projectRoot)
6
8
  upstreamConfig ??= getUpstreamConfig(projectRoot)
7
9
  const isExpo = checkIfExpo(upstreamConfig)
8
- return {
10
+ const config = {
9
11
  ...upstreamConfig,
10
12
  transformer: {
11
13
  ...upstreamConfig.transformer,
12
- babelTransformerPath: require.resolve('./metro-babel-transformer.js')
14
+ babelTransformerPath: require.resolve('./metro-babel-transformer.js'),
15
+ unstable_allowRequireContext: true
13
16
  },
14
17
  resolver: {
15
18
  ...upstreamConfig.resolver,
@@ -19,21 +22,21 @@ exports.getDefaultConfig = function getDefaultConfig (projectRoot, { upstreamCon
19
22
  ...(upstreamConfig.resolver.sourceExts || []),
20
23
  ...['mjs', 'cjs', 'md', 'mdx', 'css', 'styl', 'svg']
21
24
  ])),
22
- unstable_enablePackageExports: true
23
- },
24
- server: {
25
- ...upstreamConfig.server,
26
- // TODO: implement a simple parsing of startupjs.config.js
27
- // to figure out whether we need to load 'server' and 'isomorphic'
28
- // envs or only the 'build' one.
29
- // If $.isomorphic.server is turned off then we don't need the enhanceMiddleware at all
30
- enhanceMiddleware: metroMiddleware => {
31
- return connect()
32
- .use(metroMiddleware)
33
- .use(getStartupjsMiddleware())
34
- }
25
+ unstable_enablePackageExports: true,
26
+ requireCycleIgnorePatterns: [
27
+ ...(upstreamConfig.requireCycleIgnorePatterns || []),
28
+ /(^|\/|\\)node_modules($|\/|\\)/
29
+ ]
35
30
  }
36
31
  }
32
+ if (features.enableServer) {
33
+ config.server ??= {}
34
+ config.server.enhanceMiddleware = metroMiddleware =>
35
+ connect()
36
+ .use(metroMiddleware)
37
+ .use(getStartupjsMiddleware())
38
+ }
39
+ return config
37
40
  }
38
41
 
39
42
  function getUpstreamConfig (projectRoot) {
@@ -69,9 +72,6 @@ function checkIfExpo (upstreamConfig) {
69
72
  function getStartupjsMiddleware () {
70
73
  const middlewarePromise = (async () => {
71
74
  await import('./nodeRegister.mjs')
72
- await import('@startupjs/registry/loadStartupjsConfig.auto')
73
- const { ROOT_MODULE: MODULE } = await import('@startupjs/registry')
74
- if (!MODULE.options.server) return
75
75
  const { createMiddleware } = await import('@startupjs/server')
76
76
  return (await createMiddleware()).middleware
77
77
  })()
package/nodeLoader.mjs CHANGED
@@ -37,7 +37,7 @@ export async function load (url, context, nextLoad) {
37
37
  if (isStartupjsPluginEcosystemFile(url)) {
38
38
  const filePath = fileURLToPath(url)
39
39
  let source = await readFile(filePath, 'utf8')
40
- source = callLoader(eliminatorLoader, source, filePath, { envs: ['server', 'isomorphic'] })
40
+ source = callLoader(eliminatorLoader, source, filePath, { envs: ['features', 'isomorphic', 'server'] })
41
41
  return {
42
42
  format: 'module',
43
43
  shortCircuit: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startupjs/bundler",
3
- "version": "0.56.0-alpha.2",
3
+ "version": "0.56.0-alpha.25",
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,11 @@
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.13",
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.2",
31
- "@startupjs/server": "^0.56.0-alpha.2",
31
+ "@startupjs/server": "^0.56.0-alpha.18",
32
32
  "@svgr/core": "^8.1.0",
33
33
  "@svgr/plugin-jsx": "^8.1.0",
34
34
  "@svgr/plugin-svgo": "^8.1.0",
@@ -36,8 +36,7 @@
36
36
  "assets-webpack-plugin": "^7.1.1",
37
37
  "autoprefixer": "^10.4.0",
38
38
  "babel-loader": "^8.2.3",
39
- "babel-plugin-transform-react-pug": "^7.0.1",
40
- "babel-preset-startupjs": "^0.56.0-alpha.2",
39
+ "babel-preset-startupjs": "^0.56.0-alpha.25",
41
40
  "connect": "^3.7.0",
42
41
  "css-loader": "^6.5.0",
43
42
  "css-minimizer-webpack-plugin": "^5.0.0",
@@ -61,5 +60,5 @@
61
60
  "peerDependencies": {
62
61
  "react-native-svg": "*"
63
62
  },
64
- "gitHead": "97f1ce92de18e3300d02321986936890df822dc2"
63
+ "gitHead": "e10b46ec427e4eef5909cbf1a1c342b1b12ce0df"
65
64
  }