Skip to content

Commit

Permalink
test: ensure bundle is working (#293)
Browse files Browse the repository at this point in the history
* test: ensure bundle is working

* refactor: rename module into mjs

* fix: styled as esm module

* fix: use webpack5 with storybook
  • Loading branch information
Kikobeats authored Nov 18, 2022
1 parent 77b8760 commit 49b7d49
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 94 deletions.
5 changes: 4 additions & 1 deletion packages/hover-react/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
module.exports = { stories: ['../stories/index.js'] }
module.exports = {
stories: ['../stories/index.js'],
core: { builder: 'webpack5' }
}
12 changes: 6 additions & 6 deletions packages/hover-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"description": "Turn links into beautiful previews.",
"homepage": "https://microlink.io/sdk",
"version": "5.5.10",
"main": "dist/microlink.js",
"module": "dist/microlink.module.js",
"jsnext:main": "dist/microlink.module.js",
"main": "dist/microlink.cjs",
"module": "dist/microlink.mjs",
"jsnext:main": "dist/microlink.mjs",
"repository": {
"directory": "packages/hover-react",
"type": "git",
Expand All @@ -29,6 +29,8 @@
},
"devDependencies": {
"@babel/core": "latest",
"@storybook/builder-webpack5": "latest",
"@storybook/manager-webpack5": "latest",
"@babel/plugin-proposal-class-properties": "latest",
"@babel/plugin-proposal-object-rest-spread": "latest",
"@babel/plugin-transform-react-constant-elements": "latest",
Expand Down Expand Up @@ -95,7 +97,5 @@
},
"publishConfig": {
"access": "public"
},
"umd:main": "dist/microlink.umd.js",
"unpkg": "dist/microlink.umd.js"
}
}
23 changes: 8 additions & 15 deletions packages/hover-react/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ const plugins = ({ compress }) => [
filesize(),
visualizer({ template: 'treemap' }),
replace({
'process.env.NODE_ENV': JSON.stringify('production')
preventAssignment: true,
values: {
'process.env.NODE_ENV': JSON.stringify('production')
}
})
]

Expand All @@ -50,34 +53,24 @@ const build = ({ file, format, name, exports }) => {
}

const builds = [
build({
format: 'umd',
file: 'dist/microlink.umd.js',
name: 'microlink'
}),
build({
format: 'umd',
file: 'dist/microlink.umd.min.js',
name: 'microlink'
}),
build({
format: 'esm',
file: 'dist/microlink.module.js',
file: 'dist/microlink.mjs',
exports: 'named'
}),
build({
format: 'esm',
file: 'dist/microlink.module.min.js',
file: 'dist/microlink.min.mjs',
exports: 'named'
}),
build({
format: 'cjs',
file: 'dist/microlink.js',
file: 'dist/microlink.cjs',
exports: 'named'
}),
build({
format: 'cjs',
file: 'dist/microlink.min.js',
file: 'dist/microlink.min.cjs',
exports: 'named'
})
]
Expand Down
10 changes: 5 additions & 5 deletions packages/hover-vanilla/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"description": "Turn links into beautiful previews.",
"homepage": "https://microlink.io/sdk",
"version": "5.5.10",
"main": "dist/microlink.js",
"module": "dist/microlink.module.js",
"jsnext:main": "dist/microlink.module.js",
"main": "dist/microlink.cjs",
"module": "dist/microlink.mjs",
"jsnext:main": "dist/microlink.mjs",
"repository": {
"directory": "packages/hover-vanilla",
"type": "git",
Expand Down Expand Up @@ -54,6 +54,6 @@
"publishConfig": {
"access": "public"
},
"umd:main": "dist/microlink.umd.js",
"unpkg": "dist/microlink.umd.js"
"umd:main": "dist/microlink.js",
"unpkg": "dist/microlink.js"
}
65 changes: 29 additions & 36 deletions packages/hover-vanilla/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ const plugins = ({ compress }) =>
filesize(),
visualizer({ template: 'treemap' }),
replace({
'process.env.NODE_ENV': JSON.stringify('production')
preventAssignment: true,
values: {
'process.env.NODE_ENV': JSON.stringify('production')
}
}),
!isProduction &&
copy({
Expand Down Expand Up @@ -53,42 +56,32 @@ const builds = [
format: 'umd',
file: 'dist/microlink.js',
name: 'microlinkHover'
}),
build({
format: 'umd',
file: 'dist/microlink.min.js',
name: 'microlinkHover'
}),
build({
format: 'esm',
file: 'dist/microlink.mjs',
exports: 'named'
}),
build({
format: 'esm',
file: 'dist/microlink.min.mjs',
exports: 'named'
}),
build({
format: 'cjs',
file: 'dist/microlink.cjs',
exports: 'named'
}),
build({
format: 'cjs',
file: 'dist/microlink.min.cjs',
exports: 'named'
})
]

if (isProduction) {
builds.concat([
build({
format: 'umd',
file: 'dist/microlink.js',
name: 'microlinkHover'
}),
build({
format: 'umd',
file: 'dist/microlink.min.js',
name: 'microlinkHover'
}),
build({
format: 'esm',
file: 'dist/microlink.module.js',
exports: 'named'
}),
build({
format: 'esm',
file: 'dist/microlink.min.module.js',
exports: 'named'
}),
build({
format: 'cjs',
file: 'dist/microlink.cjs.js',
exports: 'named'
}),
build({
format: 'cjs',
file: 'dist/microlink.cjs.min.js',
exports: 'named'
})
])
}

export default builds
13 changes: 6 additions & 7 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"description": "Turn links into beautiful previews.",
"homepage": "https://microlink.io/sdk",
"version": "5.5.10",
"main": "dist/microlink.js",
"module": "dist/microlink.module.js",
"jsnext:main": "dist/microlink.module.js",
"main": "dist/microlink.cjs",
"module": "dist/microlink.mjs",
"jsnext:main": "dist/microlink.mjs",
"repository": {
"directory": "packages/react",
"type": "git",
Expand Down Expand Up @@ -78,7 +78,8 @@
"build-storybook": "NODE_ENV=production build-storybook --quiet",
"dev": "start-storybook -p 6006",
"start": "node scripts/start.js",
"test": "NODE_ENV=test jest --detectOpenHandles"
"pretest": "npm run build",
"test": "node -e \"require('./')\" && NODE_ENV=test jest --detectOpenHandles"
},
"license": "MIT",
"jest": {
Expand All @@ -96,7 +97,5 @@
},
"publishConfig": {
"access": "public"
},
"umd:main": "dist/microlink.umd.js",
"unpkg": "dist/microlink.umd.js"
}
}
24 changes: 9 additions & 15 deletions packages/react/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ const plugins = ({ compress }) => [
filesize(),
visualizer({ template: 'treemap' }),
replace({
'process.env.NODE_ENV': JSON.stringify('production')
preventAssignment: true,
values: {
'process.env.NODE_ENV': JSON.stringify('production')
}
})
]

Expand All @@ -37,6 +40,7 @@ const build = ({ file, format, name, exports }) => {
return {
input: './src/index.js',
output: {
interop: id => (id === 'styled-components' ? 'esModule' : 'default'),
sourcemap: compress,
file,
format,
Expand All @@ -50,34 +54,24 @@ const build = ({ file, format, name, exports }) => {
}

const builds = [
build({
format: 'umd',
file: 'dist/microlink.umd.js',
name: 'microlink'
}),
build({
format: 'umd',
file: 'dist/microlink.umd.min.js',
name: 'microlink'
}),
build({
format: 'esm',
file: 'dist/microlink.module.js',
file: 'dist/microlink.mjs',
exports: 'named'
}),
build({
format: 'esm',
file: 'dist/microlink.min.module.js',
file: 'dist/microlink.min.mjs',
exports: 'named'
}),
build({
format: 'cjs',
file: 'dist/microlink.js',
file: 'dist/microlink.cjs',
exports: 'named'
}),
build({
format: 'cjs',
file: 'dist/microlink.min.js',
file: 'dist/microlink.min.cjs',
exports: 'named'
})
]
Expand Down
6 changes: 3 additions & 3 deletions packages/vanilla/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"description": "Turn links into beautiful previews.",
"homepage": "https://microlink.io/sdk",
"version": "5.5.10",
"main": "dist/microlink.js",
"module": "dist/microlink.module.js",
"jsnext:main": "dist/microlink.module.js",
"main": "dist/microlink.cjs",
"module": "dist/microlink.mjs",
"jsnext:main": "dist/microlink.mjs",
"repository": {
"directory": "packages/vanilla",
"type": "git",
Expand Down
17 changes: 11 additions & 6 deletions packages/vanilla/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ const plugins = ({ compress }) => [
filesize(),
visualizer({ template: 'treemap' }),
replace({
'process.env.NODE_ENV': JSON.stringify('production')
preventAssignment: true,
values: {
'process.env.NODE_ENV': JSON.stringify('production')
}
})
]

Expand Down Expand Up @@ -40,7 +43,7 @@ const build = ({ file, format, name, exports }) => {
}
}

export default [
const builds = [
build({
format: 'umd',
file: 'dist/microlink.js',
Expand All @@ -53,22 +56,24 @@ export default [
}),
build({
format: 'esm',
file: 'dist/microlink.module.js',
file: 'dist/microlink.mjs',
exports: 'named'
}),
build({
format: 'esm',
file: 'dist/microlink.min.module.js',
file: 'dist/microlink.min.mjs',
exports: 'named'
}),
build({
format: 'cjs',
file: 'dist/microlink.cjs.js',
file: 'dist/microlink.cjs',
exports: 'named'
}),
build({
format: 'cjs',
file: 'dist/microlink.cjs.min.js',
file: 'dist/microlink.min.cjs',
exports: 'named'
})
]

export default builds

4 comments on commit 49b7d49

@vercel
Copy link

@vercel vercel bot commented on 49b7d49 Nov 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 49b7d49 Nov 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sdk-hover-vanilla – ./packages/hover-vanilla

sdk-hover-vanilla.vercel.app
sdk-hover-vanilla-git-master-microlink.vercel.app
sdk-hover-vanilla.microlink.io
sdk-hover-vanilla-microlink.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 49b7d49 Nov 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sdk-vanilla – ./packages/vanilla

sdk-vanilla.vercel.app
sdk-vanilla-microlink.vercel.app
sdk-vanilla-git-master-microlink.vercel.app
sdk-vanilla.microlink.io

@vercel
Copy link

@vercel vercel bot commented on 49b7d49 Nov 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sdk-react – ./packages/react

sdk-react.vercel.app
sdk-react-git-master-microlink.vercel.app
sdk-react-microlink.vercel.app
sdk-react.microlink.io

Please sign in to comment.