Skip to content

Commit

Permalink
fix: improves the packaging
Browse files Browse the repository at this point in the history
uses esbuild-node-externals to standardize the package - moved the test utils so they can be
excluded from the build
  • Loading branch information
stuarthendren committed Oct 11, 2022
1 parent 0a3a2dd commit a28d42d
Show file tree
Hide file tree
Showing 77 changed files with 798 additions and 182 deletions.
3 changes: 1 addition & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "yarn install",
"postCreateCommand": "npm ci",

// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "node",
Expand Down
21 changes: 15 additions & 6 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@
**/tsconfig.json
**/webpack.config.js
node_modules
src
stories
example
lib
lib-esm
_bundles
tsdx.config.js
generators
public
src
build.mjs
coverage
dangerfile.lite.ts
dangerfile.ts
jest.config.js
jest.patch-cssom.js
sonar-project.properties
spellcheck.json
test-report.xml
tsconfig.build.json
tsconfig.json
tsconfig.storybook.json
8 changes: 4 additions & 4 deletions build.js → build.mjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
const { build } = require('esbuild')
const { peerDependencies } = require('./package.json')
import { build } from 'esbuild'
import { nodeExternalsPlugin } from 'esbuild-node-externals'

const entryFile = 'src/index.ts'
const outFolder = 'dist'

const shared = {
bundle: true,
entryPoints: [entryFile],
external: Object.keys(peerDependencies),
logLevel: 'info',
minify: true,
sourcemap: true,
target: ['esnext', 'node12.22.0'],
target: ['esnext'],
plugins: [nodeExternalsPlugin()],
}

build({
Expand Down
19 changes: 6 additions & 13 deletions generators/Component.test.hbs
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import React from 'react'
import { renderLight, renderDark } from 'test-utils'
import { Default } from './{{ name }}.stories'

it('renders light without error', () => {
const { asFragment } = renderLight(<Default />)
expect(asFragment()).toBeDefined()
})

it('renders dark without error', () => {
const { asFragment } = renderDark(<Default />)
expect(asFragment()).toBeDefined()
})
import React from 'react' import { renderLight, renderDark } from '../../test'
import { Default } from './{{name}}.stories' it('renders light without error',
() => { const { asFragment } = renderLight(<Default />)
expect(asFragment()).toBeDefined() }) it('renders dark without error', () => {
const { asFragment } = renderDark(<Default />)
expect(asFragment()).toBeDefined() })
Loading

0 comments on commit a28d42d

Please sign in to comment.