Skip to content

Commit

Permalink
removed dist thing to work with pnpm
Browse files Browse the repository at this point in the history
  • Loading branch information
remorses committed Aug 8, 2023
1 parent cbf46ef commit d56d00b
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 90 deletions.
16 changes: 15 additions & 1 deletion example-npm/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion example-npm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"keywords": [],
"author": "Tommaso De Rossi, morse <[email protected]>",
"dependencies": {
"avatar-jptx": "http://localhost:3000/api/m/[email protected]?xxsdfdszzzsdfasfdasdfsdf"
"avatar-jptx": "http://localhost:2323/api/m/[email protected]?xxsdfdszzzsdfasfdasdfsdf",
"pricing-table-gmzp": "http://localhost:2323/m/Pricing-Table-gmzP.js@gwFmseXxhUO3VHfFNdaT#aaaaax"
},
"license": "ISC"
}
34 changes: 0 additions & 34 deletions nextjs-app/README.md

This file was deleted.

45 changes: 2 additions & 43 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"dev": "next dev -p 2323",
"build": "next build",
"start": "next start",
"lint": "next lint"
Expand Down
20 changes: 10 additions & 10 deletions server/src/exporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export async function bundle({ cwd = '', url }) {
const deps = new Set<string>()
cwd ||= path.resolve(process.cwd(), 'example')
cwd = path.resolve(cwd)
fs.mkdirSync(path.resolve(cwd, './dist'), { recursive: true })
fs.mkdirSync(path.resolve(cwd), { recursive: true })
const peerDependencies = {
react: '*',
'react-dom': '*',
Expand Down Expand Up @@ -65,10 +65,10 @@ export async function bundle({ cwd = '', url }) {
],
write: true,
// outfile: 'dist/example.js',
outdir: path.resolve(cwd, 'dist'),
outdir: path.resolve(cwd),
})
// logger.log('result', result)
const resultFile = path.resolve(cwd, './dist/main.js')
const resultFile = path.resolve(cwd, './main.js')
// TODO this is a vulnerability, i need to sandbox this somehow
const propControls = await extractPropControls(url)
const types = propControlsToType(propControls)
Expand All @@ -86,12 +86,12 @@ export async function bundle({ cwd = '', url }) {
const packageJson = {
name: name,
version: '0.0.0',
main: 'dist/main.js',
types: types ? 'dist/main.d.ts' : undefined,
module: 'dist/main.js',
main: 'main.js',
types: types ? 'main.d.ts' : undefined,
module: 'main.js',
// files: ['dist', 'package.json'],
exports: {
'.': 'dist/main.js',
'.': 'main.js',
'./package.json': './package.json',
},
type: 'module',
Expand All @@ -116,7 +116,7 @@ export async function bundle({ cwd = '', url }) {
path.resolve(cwd, 'package.json'),
JSON.stringify(packageJson, null, 2),
)
fs.writeFileSync(path.resolve(cwd, 'dist/main.d.ts'), types)
fs.writeFileSync(path.resolve(cwd, 'main.d.ts'), types)
return {
resultFile,
packageJson,
Expand All @@ -125,15 +125,15 @@ export async function bundle({ cwd = '', url }) {

files: [
{
name: 'dist/main.d.ts',
name: './main.d.ts',
content: types,
},
{
name: './package.json',
content: JSON.stringify(packageJson, null, 2),
},
{
name: 'dist/main.js',
name: './main.js',
content: fs.readFileSync(resultFile, 'utf-8'),
},
],
Expand Down
21 changes: 21 additions & 0 deletions server/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from 'vitest'
import fs from 'fs'
import { build } from 'esbuild'
import {
bundle,
Expand All @@ -7,6 +8,9 @@ import {
parsePropertyControls,
} from './exporter'
import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill'
import { execSync } from 'child_process'
import { tmpdir } from 'os'
import path from 'path'

test(
'bundle',
Expand All @@ -20,6 +24,23 @@ test(
},
1000 * 10,
)
test.skip(
'server',
async () => {
const zip = path.resolve('example-download/zip.tar.gz')
const out = path.resolve(path.dirname(zip), 'uzipped')
fs.mkdirSync(out, { recursive: true })
console.log('downloading to ', zip)
execSync(
`curl -o ${zip} http://localhost:2323/m/Mega-Menu-2wT3.js@W0zNsrcZ2WAwVuzt0BCl`,
{ stdio: 'inherit' },
)
execSync(`unzip ${zip} `, { stdio: 'inherit' })
execSync(`tree ${zip}`, { stdio: 'inherit' })
},
1000 * 100,
)

test(
'parsePropertyControls',
async () => {
Expand Down

0 comments on commit d56d00b

Please sign in to comment.