Skip to content

Commit

Permalink
Merge pull request #1131 from dnbexperience/main
Browse files Browse the repository at this point in the history
  • Loading branch information
tujoworker authored Nov 16, 2021
2 parents 6ff7683 + 34f31f6 commit 11b8fab
Show file tree
Hide file tree
Showing 23 changed files with 144 additions and 78 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/build-check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Check
name: Build Check # This name is used in the release.yml workflow_run event

on:
push:
Expand All @@ -8,6 +8,10 @@ on:
- '!**--visual-reports'
- '!wip/**'
- '!experiments/**'
- '!release'
- '!portal'
- '!beta'
- '!alpha'
pull_request:
branches:
- 'main'
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ on:
- '!**--visual-reports'
- '!wip/**'
- '!experiments/**'
- '!release'
- '!portal'
- '!beta'
- '!alpha'

jobs:
action:
Expand Down
1 change: 1 addition & 0 deletions packages/dnb-design-system-portal/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
],
"plugins": ["react", "react-hooks", "jsx-a11y"],
"rules": {
"react/react-in-jsx-scope": "off",
"no-console": "off",
"react/prop-types": "warn",
"react/require-default-props": "warn",
Expand Down
1 change: 1 addition & 0 deletions packages/dnb-design-system-portal/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,5 @@ module.exports = {
pathPrefix,
siteMetadata,
plugins,
jsxRuntime: 'automatic',
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*
*/

import React from 'react'
import ComponentBox from 'dnb-design-system-portal/src/shared/tags/ComponentBox'

export const BreadcrumbSingle = () => (
Expand Down
1 change: 1 addition & 0 deletions packages/dnb-eufemia/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"security"
],
"rules": {
"react/react-in-jsx-scope": "off",
"import/namespace": "off",
"no-restricted-imports": [
"error",
Expand Down
78 changes: 47 additions & 31 deletions packages/dnb-eufemia/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
/* stylelint-disable */
/**
* Main Babel config
*
*/

const presets =
const basisPresets = [
'@babel/preset-react',
['@babel/preset-typescript', { isTSX: true, allExtensions: true }],
]

const presetsGeneral =
process.env.BABEL_ENV === 'es'
? [
'@babel/preset-react',
['@babel/preset-typescript', { isTSX: true, allExtensions: true }],
]
? basisPresets
: [
[
// Using .browserslistrc for the targets
Expand All @@ -20,25 +21,51 @@ const presets =
: 'cjs',
},
],
'@babel/preset-react',
['@babel/preset-typescript', { isTSX: true, allExtensions: true }],

...basisPresets,
]

// also for IE testing with Storybook}
const legacy =
// Used for legacy, IE11 builds
const legacyPresets =
process.env.BABEL_ENV === 'es'
? []
: [
// Include the rest
...presetsGeneral,

// Manipulate @babel/preset-env
[
presets[0][0], // get preset id
presetsGeneral[0][0], // get preset id
{
...presets[0][1], // get preset options
...presetsGeneral[0][1], // get preset options
useBuiltIns: 'usage',
corejs: 3,
},
],
presets[1],
]
.slice(1) // remove the first "presetsGeneral"
.reverse()

const testingPresets =
process.env.BABEL_ENV === 'es'
? []
: [
// Include the rest
...presetsGeneral,

// Manipulate @babel/preset-env
[
presetsGeneral[0][0], // get preset id
{
...presetsGeneral[0][1], // get preset options
targets: {
node: 'current',
},
},
],
]
.slice(1) // remove the first "presetsGeneral"
.reverse()

const productionPlugins = [
'@babel/plugin-transform-react-constant-elements',
Expand All @@ -65,7 +92,7 @@ if (typeof process.env.BABEL_ENV !== 'undefined') {
}

const config = {
presets,
presets: presetsGeneral,
plugins: [
'babel-plugin-optimize-clsx',
'@babel/plugin-proposal-export-default-from',
Expand All @@ -79,13 +106,13 @@ const config = {
ignore: ['node_modules/**'],
env: {
cjs: {
presets: legacy,
presets: legacyPresets,
plugins: productionPlugins.concat([
'@babel/plugin-transform-modules-commonjs',
]),
},
esm: {
presets: legacy,
presets: legacyPresets,
plugins: [
...productionPlugins,
['@babel/plugin-transform-runtime', { useESModules: true }],
Expand All @@ -98,33 +125,22 @@ const config = {
],
},
umd: {
presets: legacy,
presets: legacyPresets,
plugins: [
...productionPlugins,
['@babel/plugin-transform-runtime', { useESModules: true }],
],
},
production: {
presets: legacy,
presets: legacyPresets,
plugins: [
...productionPlugins,
['@babel/plugin-transform-runtime', { useESModules: true }],
],
},
development: { presets: legacy },
development: { presets: presetsGeneral },
test: {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
'@babel/preset-react',
['@babel/preset-typescript', { isTSX: true, allExtensions: true }],
],
presets: testingPresets,
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"audit:ci:yarn-outdated": "babel-node ./scripts/prepub/audit/toOpt && audit-ci --config ./audit-ci.json --package-manager=yarn --report-type full && babel-node ./scripts/prepub/audit/toDev",
"build": "yarn build:prebuild && yarn build:esm && yarn build:copy",
"prebuild:ci": "yarn build",
"postbuild:ci": "./scripts/release/postbuild.sh",
"postbuild:ci": "./scripts/release/postbuild.sh && yarn test:build",
"build:cjs": "./scripts/release/babel-cjs.sh",
"build:clean": "rm -rf build/**",
"build:copy": "./scripts/release/copy-build-artifacts.sh",
Expand Down
9 changes: 7 additions & 2 deletions packages/dnb-eufemia/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const excludes = [
]

const currentBranch = branchName()
export default isCI && !/^(release|beta|alpha)$/.test(currentBranch)
export default !/^(release|beta|alpha)$/.test(currentBranch)
? [
// NB: rollup needs at least one config
makeRollupConfig(
Expand Down Expand Up @@ -204,7 +204,10 @@ function makeRollupConfig(
}
})

const extensions = ['.js', '.ts', '.tsx']

const babelOptions = {
extensions,
exclude: /node_modules/,
babelHelpers: 'runtime', // using @babel/plugin-transform-runtime
configFile: './babel.config.js',
Expand All @@ -226,7 +229,9 @@ function makeRollupConfig(
},
external,
plugins: [
nodeResolve(),
nodeResolve({
extensions,
}),
babel(babelOptions),
commonjs(commonjsOptions),
nodeGlobals(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,14 @@ describe('babel build', () => {
break
}

{
if (stage == 'cjs') {
const exists = fs.existsSync(
path.resolve(
`./build/${stage}/components/breadcrumb/Breadcrumb.tsx`
)
)
expect(exists).toBe(false)
} else {
const content = fs.readFileSync(
path.resolve(
`./build/${stage}/components/breadcrumb/Breadcrumb.tsx`
Expand Down
4 changes: 2 additions & 2 deletions packages/dnb-eufemia/scripts/release/babel-cjs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ babel ./src \

echo 'Building cjs bundle done!'

echo 'Copy .d.ts files to cjs ...'
echo 'Copy additional files to cjs ...'

OUT_DIR=./build/cjs babel-node ./scripts/release/copyTypeScriptFiles.js
OUT_DIR=./build/cjs ONLY_DEFINITION_FILES=1 babel-node ./scripts/release/copyTypeScriptFiles.js
OUT_DIR=./build/cjs babel-node ./scripts/release/copyStyles.js

echo 'Copy extra cjs package.json ...'
Expand Down
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/scripts/release/babel-es.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ babel ./src \

echo 'Building es bundle done!'

echo 'Copy .d.ts files to es ...'
echo 'Copy additional files to es ...'

OUT_DIR=./build/es babel-node ./scripts/release/copyTypeScriptFiles.js
OUT_DIR=./build/es babel-node ./scripts/release/copyStyles.js
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/scripts/release/babel-esm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ babel ./src \

echo 'Building esm bundle done!'

echo 'Copy .d.ts files to esm ...'
echo 'Copy additional files to esm ...'

OUT_DIR=./build/esm babel-node ./scripts/release/copyTypeScriptFiles.js
OUT_DIR=./build/esm babel-node ./scripts/release/copyStyles.js
14 changes: 8 additions & 6 deletions packages/dnb-eufemia/scripts/release/copyTypeScriptFiles.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copy .d.ts files recursively
* Copy additional files recursively
*
*/

Expand All @@ -12,11 +12,13 @@ if (require.main === module) {
}

async function copyTypeScriptFiles(dist) {
const files = await globby([
'./src/**/*.ts',
'./src/**/*.tsx',
'./src/**/*.d.ts',
])
const globbyFiles = ['./src/**/*.d.ts']

if (process.env.ONLY_DEFINITION_FILES !== '1') {
globbyFiles.push('./src/**/*.ts', './src/**/*.tsx')
}

const files = await globby(globbyFiles)

for await (const file of files) {
const src = path.resolve(file)
Expand Down
1 change: 0 additions & 1 deletion packages/dnb-eufemia/scripts/release/postbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ yarn build:umd
echo 'Can be enabled in future if needed -> yarn build:resources'
yarn build:copy
yarn prettier:other
yarn test:build

echo 'Postbuild done!'
16 changes: 11 additions & 5 deletions packages/dnb-eufemia/src/components/breadcrumb/Breadcrumb.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import React, { useEffect, useState } from 'react'
import BreadcrumbItem, { BreadcrumbItemProps } from './BreadcrumbItem'
import Context from '../../shared/Context'
import { ISpacingProps, SkeletonTypes } from '../../shared/interfaces'
import classnames from 'classnames'

// Components
import { createSkeletonClass } from '../skeleton/SkeletonHelper'
import Section from '../section/Section'
import { createSpacingClasses } from '../space/SpacingHelper'
import Section from '../section/Section'
import Button from '../button/Button'

// Shared
import { useMediaQuery } from '../../shared'
import Context from '../../shared/Context'
import { ISpacingProps, SkeletonTypes } from '../../shared/interfaces'
import { extendPropsWithContext } from '../../shared/component-helper'
import { Button } from '..'

// Internal
import BreadcrumbItem, { BreadcrumbItemProps } from './BreadcrumbItem'

export * from './BreadcrumbItem'

Expand Down
17 changes: 12 additions & 5 deletions packages/dnb-eufemia/src/components/breadcrumb/BreadcrumbItem.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import React from 'react'
import Context from '../../shared/Context'
import Button from '../Button'
import homeIcon from '../../icons/home'

// Components
import Button from '../button/Button'
import IconPrimary, { IconPrimaryIcon } from '../icon-primary/IconPrimary'

// Elements
import P from '../../elements/P'
import { IconPrimary } from '..'
import { IconPrimaryIcon } from '../icon-primary/IconPrimary'

// Icons
import homeIcon from '../../icons/home'

// Shared
import Context from '../../shared/Context'
import { SkeletonTypes } from '../../shared/interfaces'
import { extendPropsWithContext } from '../../shared/component-helper'

Expand Down
Loading

0 comments on commit 11b8fab

Please sign in to comment.