@startupjs/bundler 0.41.4 → 0.43.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.
- package/lib/cssToReactNativeLoader.js +8 -0
- package/lib/rnTransformer.js +0 -5
- package/package.json +5 -4
- package/webpack.web.config.js +12 -16
|
@@ -9,6 +9,8 @@ module.exports = function cssToReactNative (source) {
|
|
|
9
9
|
for (const key in cssObject.__exportProps || {}) {
|
|
10
10
|
cssObject[key] = parseStylValue(cssObject.__exportProps[key])
|
|
11
11
|
}
|
|
12
|
+
// save hash to use with the caching system of @startupjs/cache
|
|
13
|
+
cssObject.__hash__ = simpleNumericHash(JSON.stringify(cssObject))
|
|
12
14
|
return 'module.exports = ' + JSON.stringify(cssObject)
|
|
13
15
|
}
|
|
14
16
|
|
|
@@ -76,3 +78,9 @@ function escapeExport (source) {
|
|
|
76
78
|
|
|
77
79
|
return source
|
|
78
80
|
}
|
|
81
|
+
|
|
82
|
+
// ref: https://gist.github.com/hyamamoto/fd435505d29ebfa3d9716fd2be8d42f0?permalink_comment_id=2694461#gistcomment-2694461
|
|
83
|
+
function simpleNumericHash (s) {
|
|
84
|
+
for (var i = 0, h = 0; i < s.length; i++) h = Math.imul(31, h) + s.charCodeAt(i) | 0
|
|
85
|
+
return h
|
|
86
|
+
}
|
package/lib/rnTransformer.js
CHANGED
|
@@ -7,7 +7,6 @@ const stylusToCssLoader = require('./stylusToCssLoader')
|
|
|
7
7
|
const cssToReactNativeLoader = require('./cssToReactNativeLoader')
|
|
8
8
|
const mdxExamplesLoader = require('./mdxExamplesLoader')
|
|
9
9
|
const mdxLoader = require('./mdxLoader')
|
|
10
|
-
const replaceObserverLoader = require('./replaceObserverLoader')
|
|
11
10
|
const callLoader = require('./callLoader')
|
|
12
11
|
|
|
13
12
|
module.exports.transform = function ({ src, filename, options = {} }) {
|
|
@@ -24,10 +23,6 @@ module.exports.transform = function ({ src, filename, options = {} }) {
|
|
|
24
23
|
} else if (/\.svg$/.test(filename)) {
|
|
25
24
|
return svgTransformer.transform({ src, filename, options })
|
|
26
25
|
} else if (/\.[cm]?jsx?$/.test(filename) && /['"]startupjs['"]/.test(src)) {
|
|
27
|
-
// Fix Fast Refresh to work with observer() decorator.
|
|
28
|
-
// For details view ./replaceObserverLoader.js
|
|
29
|
-
src = src.replace(/(?:\/\*(?:[\s\S]*?)\*\/)|(?:^\s*\/\/(?:.*)$)/gm, '')
|
|
30
|
-
src = callLoader(replaceObserverLoader, src, filename)
|
|
31
26
|
return upstreamTransformer.transform({ src, filename, options })
|
|
32
27
|
} else if (/\.mdx?$/.test(filename)) {
|
|
33
28
|
src = callLoader(mdxExamplesLoader, src, filename)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startupjs/bundler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.43.0",
|
|
4
4
|
"description": "Opinionated scripts and configs to develop a react-native-web project",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -19,13 +19,14 @@
|
|
|
19
19
|
"@mdx-js/loader": "^1.6.22",
|
|
20
20
|
"@mdx-js/mdx": "^1.6.22",
|
|
21
21
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.1",
|
|
22
|
+
"@startupjs/babel-plugin-react-css-modules": "^6.5.4-1",
|
|
22
23
|
"@startupjs/css-to-react-native-transform": "^1.9.0-1",
|
|
23
|
-
"@startupjs/plugin": "^0.
|
|
24
|
+
"@startupjs/plugin": "^0.43.0",
|
|
24
25
|
"@svgr/webpack": "~5.5.0",
|
|
25
26
|
"assets-webpack-plugin": "^7.1.1",
|
|
26
27
|
"autoprefixer": "^10.4.0",
|
|
27
28
|
"babel-loader": "^8.2.3",
|
|
28
|
-
"babel-preset-startupjs": "^0.
|
|
29
|
+
"babel-preset-startupjs": "^0.43.0",
|
|
29
30
|
"css-loader": "^6.5.0",
|
|
30
31
|
"css-minimizer-webpack-plugin": "^3.1.1",
|
|
31
32
|
"file-loader": "^6.2.0",
|
|
@@ -49,5 +50,5 @@
|
|
|
49
50
|
"peerDependencies": {
|
|
50
51
|
"react-native-svg": ">= 12.1.0"
|
|
51
52
|
},
|
|
52
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "71591aee88a27e1726252d560c5a1d99fa86b559"
|
|
53
54
|
}
|
package/webpack.web.config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { getPluginConfigs } = require('@startupjs/plugin/manager.cjs')
|
|
2
|
+
const { getLocalIdent } = require('@startupjs/babel-plugin-react-css-modules/utils')
|
|
2
3
|
const pickBy = require('lodash/pickBy')
|
|
3
|
-
const pick = require('lodash/pick')
|
|
4
4
|
const fs = require('fs')
|
|
5
5
|
const path = require('path')
|
|
6
6
|
const AssetsPlugin = require('assets-webpack-plugin')
|
|
@@ -18,7 +18,6 @@ const BUILD_PATH = path.join(process.cwd(), BUILD_DIR)
|
|
|
18
18
|
const BUNDLE_NAME = 'main'
|
|
19
19
|
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin')
|
|
20
20
|
const webpack = require('webpack')
|
|
21
|
-
const { getJsxRule } = require('./helpers')
|
|
22
21
|
const DEFAULT_MODE = 'react-native'
|
|
23
22
|
const PLUGINS = getPluginConfigs()
|
|
24
23
|
|
|
@@ -34,7 +33,8 @@ const DEFAULT_ALIAS = {
|
|
|
34
33
|
// fix warning requiring './locale': https://github.com/moment/moment/issues/1435
|
|
35
34
|
moment$: 'moment/moment.js',
|
|
36
35
|
'react-native': 'react-native-web',
|
|
37
|
-
'react-router-native': 'react-router-dom'
|
|
36
|
+
'react-router-native': 'react-router-dom',
|
|
37
|
+
'@fortawesome/react-native-fontawesome': '@fortawesome/react-fontawesome'
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
let DEFAULT_ENTRIES = [
|
|
@@ -185,36 +185,30 @@ module.exports = function getConfig (env, {
|
|
|
185
185
|
module: {
|
|
186
186
|
rules: [
|
|
187
187
|
{
|
|
188
|
-
test:
|
|
188
|
+
test: /\.[mc]?[jt]sx?$/,
|
|
189
189
|
resolve: {
|
|
190
190
|
fullySpecified: false
|
|
191
191
|
},
|
|
192
192
|
exclude: /node_modules/,
|
|
193
193
|
use: [
|
|
194
|
-
|
|
195
|
-
{
|
|
196
|
-
loader: require.resolve('./lib/replaceObserverLoader.js')
|
|
197
|
-
}
|
|
194
|
+
{ loader: 'babel-loader' }
|
|
198
195
|
]
|
|
199
196
|
},
|
|
200
197
|
{
|
|
201
|
-
test:
|
|
198
|
+
test: /\.[mc]?[jt]sx?$/,
|
|
202
199
|
resolve: {
|
|
203
200
|
fullySpecified: false
|
|
204
201
|
},
|
|
205
202
|
include: new RegExp(`node_modules/(?:react-native-(?!web)|${forceCompileModules.join('|')})`),
|
|
206
203
|
use: [
|
|
207
|
-
|
|
208
|
-
{
|
|
209
|
-
loader: require.resolve('./lib/replaceObserverLoader.js')
|
|
210
|
-
}
|
|
204
|
+
{ loader: 'babel-loader' }
|
|
211
205
|
]
|
|
212
206
|
},
|
|
213
207
|
{
|
|
214
208
|
test: /\.mdx?$/,
|
|
215
209
|
exclude: /node_modules/,
|
|
216
210
|
use: [
|
|
217
|
-
|
|
211
|
+
{ loader: 'babel-loader' },
|
|
218
212
|
{
|
|
219
213
|
loader: '@mdx-js/loader'
|
|
220
214
|
},
|
|
@@ -251,6 +245,7 @@ module.exports = function getConfig (env, {
|
|
|
251
245
|
loader: 'css-loader',
|
|
252
246
|
options: {
|
|
253
247
|
modules: {
|
|
248
|
+
getLocalIdent,
|
|
254
249
|
localIdentName: LOCAL_IDENT_NAME
|
|
255
250
|
}
|
|
256
251
|
}
|
|
@@ -276,7 +271,7 @@ module.exports = function getConfig (env, {
|
|
|
276
271
|
}
|
|
277
272
|
}
|
|
278
273
|
] : [
|
|
279
|
-
|
|
274
|
+
{ loader: 'babel-loader' },
|
|
280
275
|
{
|
|
281
276
|
loader: require.resolve('./lib/cssToReactNativeLoader.js')
|
|
282
277
|
},
|
|
@@ -299,12 +294,13 @@ module.exports = function getConfig (env, {
|
|
|
299
294
|
loader: 'css-loader',
|
|
300
295
|
options: {
|
|
301
296
|
modules: {
|
|
297
|
+
getLocalIdent,
|
|
302
298
|
localIdentName: LOCAL_IDENT_NAME
|
|
303
299
|
}
|
|
304
300
|
}
|
|
305
301
|
}
|
|
306
302
|
] : [
|
|
307
|
-
|
|
303
|
+
{ loader: 'babel-loader' },
|
|
308
304
|
{
|
|
309
305
|
loader: require.resolve('./lib/cssToReactNativeLoader.js')
|
|
310
306
|
}
|