Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: convert __examples__ to esm #1735

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/__examples__/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
node_modules/
__build__/
.babel-cache
*.asketch.json
prop-data.json
15 changes: 9 additions & 6 deletions packages/__examples__/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@
* SOFTWARE.
*/

import { dirname, join } from 'path'
// import { dirname, join } from 'path'
import type { StorybookConfig } from '@storybook/react-webpack5'

module.exports = {
const config: StorybookConfig = {
stories: ['./stories/stories.ts'],
typescript: {
check: false,
reactDocgen: false
},
framework: getAbsolutePath('@storybook/react-webpack5'),
framework: '@storybook/react-webpack5',
docs: {
autodocs: false
},
Expand All @@ -41,6 +42,8 @@ module.exports = {
}
}

function getAbsolutePath(value: string) {
return dirname(require.resolve(join(value, 'package.json')))
}
// function getAbsolutePath(value: string) {
// return dirname(require.resolve(join(value, 'package.json')))
// }

export default config

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
*/

const outputName = 'prop-data.json'
// eslint-disable-next-line no-console
// eslint-disable-next-line no-console, no-undef
console.log('starting to build example prop combinations to ' + outputName)

import { readFileSync, writeFileSync } from 'fs'
import { resolve, dirname } from 'path'
import { fileURLToPath } from 'url'
import { globby } from 'globby'
import parsePropValues from './parsePropValues.mjs'
import parsePropValues from './parsePropValues.js'
const projectRoot = resolve(dirname(fileURLToPath(import.meta.url)), '../../')

async function buildExamplesJSON() {
Expand All @@ -42,9 +42,7 @@ async function buildExamplesJSON() {
'**/es/**',
'**/template/**'
]
const ignore = ignorePaths.map(
(file) => '!' + resolve(projectRoot, file)
)
const ignore = ignorePaths.map((file) => '!' + resolve(projectRoot, file))
const matches = await globby([files, ...ignore])
const componentProps = matches.reduce((result, absoluteExampleFilePath) => {
// path to the component that is tested, e.g. /ui-tag/src/Tag/index.js
Expand Down Expand Up @@ -81,7 +79,7 @@ async function buildExamplesJSON() {

writeFileSync(outputName, everything)

// eslint-disable-next-line no-console
// eslint-disable-next-line no-console, no-undef
console.log('finished generating example prop combinations.')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,16 @@ import { builtinResolvers, parse, makeFsImporter } from 'react-docgen'
export default function parsePropValues(fileSource, fileName) {
let parsedSrc = {}
try {
parsedSrc = parse(
fileSource,
{
resolver: new builtinResolvers.FindExportedDefinitionsResolver(),
filename: fileName,
importer: makeFsImporter()
}
)
parsedSrc = parse(fileSource, {
resolver: new builtinResolvers.FindExportedDefinitionsResolver(),
filename: fileName,
importer: makeFsImporter()
})
if (Array.isArray(parsedSrc)) {
parsedSrc = parsedSrc.shift()
}
} catch (error) {
throw new Error(
`[__examples__] Could not parse component source: ${error}`
)
throw new Error(`[__examples__] Could not parse component source: ${error}`)
}

return getPropValuesFromParsedProps(parsedSrc.props)
Expand Down
3 changes: 2 additions & 1 deletion packages/__examples__/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"version": "10.3.0",
"author": "Instructure, Inc. Engineering and Product Design",
"type": "module",
"repository": {
"type": "git",
"url": "https://github.com/instructure/instructure-ui.git"
Expand All @@ -16,7 +17,7 @@
"start:watch": "npm run build:examples && npm run watch:examples",
"bundle": "npm run build:examples && npm run build:storybook",
"clean": "ui-scripts clean",
"build:examples": "node buildScripts/build-examples-json.mjs",
"build:examples": "node buildScripts/buildExamplesJson.js",
"build:storybook": "ui-scripts examples",
"watch:examples": "ui-scripts examples --watch -p 9090"
},
Expand Down
27 changes: 0 additions & 27 deletions packages/__examples__/story2sketch.config.js

This file was deleted.

Loading