Skip to content

Commit

Permalink
Trying an alternative way of importing wdyr
Browse files Browse the repository at this point in the history
  • Loading branch information
thom4parisot committed Dec 15, 2022
1 parent 15406a1 commit c030881
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"version": "dev",
"license": "MIT",
"type": "module",
"#browserlist#": "https://browserslist.dev/?q=bGFzdCAzIHZlcnNpb25zLCBzYWZhcmkgPj0gMTAsIG5vdCBleHBsb3JlciA8PSAxMSwgbm90IGV4cGxvcmVybW9iaWxlIDw9IDEx",
"#browserlist#": "https://browserslist.dev/?q=ZGVmYXVsdHMsIGxhc3QgMiB2ZXJzaW9ucywgbm90IGRlYWQsID4gMC4yJQ%3D%3D",
"browserslist": "defaults, last 2 versions, not dead, > 0.2%",
"engines": {
"node": ">=18",
Expand Down
6 changes: 3 additions & 3 deletions front/src/wdyr.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import * as React from 'react'
import * as ReactRedux from 'react-redux'
import whyDidYouRender from '@welldone-software/why-did-you-render'

if (import.meta.env.DEV) {
const {default: whyDidYouRender} = await import('@welldone-software/why-did-you-render');
const ReactRedux = await import('react-redux/lib')

whyDidYouRender(React, {
trackAllPureComponents: true,
Expand Down
8 changes: 5 additions & 3 deletions front/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import legacy from '@vitejs/plugin-legacy'
import handlebars from 'vite-plugin-handlebars'

const require = createRequire(import.meta.url)
const { version } = require('./package.json')
const { version, browserlist: target } = require('./package.json')

const { NODE_ENV, SNOWPACK_MATOMO_URL, SNOWPACK_MATOMO_SITE_ID } = env

Expand All @@ -26,8 +26,10 @@ export default defineConfig({
}
},
plugins: [
react(),
legacy(),
react({
jsxImportSource: NODE_ENV === 'development' ? '@welldone-software/why-did-you-render' : 'react'
}),
legacy({ target }),
handlebars({
context: {
NODE_ENV,
Expand Down

0 comments on commit c030881

Please sign in to comment.