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/update dependencies #12

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 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
5 changes: 1 addition & 4 deletions .config/husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn commit message lint
yarn commit message lint
5 changes: 1 addition & 4 deletions .config/husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn commit staged
yarn commit staged
5 changes: 1 addition & 4 deletions .config/husky/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn commit message $@
yarn commit message $@
122 changes: 103 additions & 19 deletions .pnp.cjs

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

1,843 changes: 0 additions & 1,843 deletions .yarn/releases/yarn-0.0.1-git.20230911.hash-1c44e15.cjs

This file was deleted.

1,160 changes: 556 additions & 604 deletions .yarn/releases/yarn.cjs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions packages/stack-trace/integration/fixtures/simple.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
const repeat = require('repeat-string')

// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
const { parse } = require('../../src')

export class Target {
Expand Down
10 changes: 8 additions & 2 deletions packages/stack-trace/integration/webpack.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import path from 'path'
import webpack from 'webpack'
import { describe } from '@jest/globals'
import { beforeAll } from '@jest/globals'
import { it } from '@jest/globals'
import { expect } from '@jest/globals'
import path from 'path'
import webpack from 'webpack'

describe('webpack stack trace', () => {
beforeAll(async () => {
Expand Down Expand Up @@ -37,8 +41,10 @@ describe('webpack stack trace', () => {
it('simple', () => {
const entryPath = path.join(__dirname, 'fixtures', 'dist', 'simple.js')

// eslint-disable-next-line security/detect-non-literal-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
const { Target } = require(entryPath)

// eslint-disable-next-line @typescript-eslint/no-unsafe-call
const stackTrace = Target.parseErrorStack()

const [repeatStringFrame, simpleFrame] = stackTrace.frames
Expand Down
15 changes: 8 additions & 7 deletions packages/stack-trace/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@atls/stack-trace",
"version": "0.0.2",
"version": "0.0.3",
"license": "BSD-3-Clause",
"main": "src/index.ts",
"files": [
Expand All @@ -12,16 +12,17 @@
"postpack": "rm -rf dist"
},
"dependencies": {
"@atls/webpack-source-map": "workspace:0.0.2",
"@atls/webpack-source-map": "workspace:*",
"stack-utils": "2.0.6"
},
"devDependencies": {
"@types/node": "20.6.3",
"@types/repeat-string": "1.6.3",
"@types/stack-utils": "2.0.1",
"@jest/globals": "29.7.0",
"@types/node": "22.7.5",
"@types/repeat-string": "1.6.5",
"@types/stack-utils": "2.0.3",
"repeat-string": "1.6.1",
"ts-loader": "9.4.4",
"webpack": "5.78.0"
"ts-loader": "9.5.1",
"webpack": "5.95.0"
},
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion packages/stack-trace/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// @ts-ignore
// @ts-expect-error
export const isWebpackEnv = typeof __webpack_require__ === 'function'
export const isProdEnv = process.env.NODE_ENV === 'production'
13 changes: 8 additions & 5 deletions packages/stack-trace/src/parse.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { StackFrame } from './stack-trace'
import { parse } from './parse'
import { describe } from '@jest/globals'
import { it } from '@jest/globals'
import { expect } from '@jest/globals'

import { parse } from './parse'

describe('parse stack trace', () => {
it('simple', () => {
const stackTrace = parse(new Error('simple').stack as string)
const topFrame = stackTrace.topFrame as StackFrame
const stackTrace = parse(new Error('simple').stack!)
const topFrame = stackTrace.topFrame!

expect(topFrame).toBeDefined()
expect(__filename).toEqual(expect.stringContaining(topFrame.file as string))
expect(__filename).toEqual(expect.stringContaining(topFrame.file!))
})
})
15 changes: 8 additions & 7 deletions packages/stack-trace/src/parse.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import StackUtils from 'stack-utils'
import type { StackFrame } from './stack-trace.js'

import { resolve } from '@atls/webpack-source-map'
import StackUtils from 'stack-utils'

import { StackTrace } from './stack-trace'
import { StackFrame } from './stack-trace'
import { isWebpackEnv } from './constants'
import { isProdEnv } from './constants'
import { resolve } from '@atls/webpack-source-map'

import { StackTrace } from './stack-trace'
import { isWebpackEnv } from './constants'
import { isProdEnv } from './constants'

export const parse = (stack: string): StackTrace => {
const lines = stack.split('\n')

const cwd = process.cwd()
const stackUtils = new StackUtils({ cwd })

const frames = lines.reduce((result: StackFrame[], line) => {
const frames = lines.reduce((result: Array<StackFrame>, line) => {
const frame: StackFrame | null = stackUtils.parseLine(line.trim())

if (frame) {
Expand Down
8 changes: 4 additions & 4 deletions packages/stack-trace/src/stack-trace.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SourceMap } from 'module'
import { StackLineData } from 'stack-utils'
import type { SourceMap } from 'module'
import type { StackLineData } from 'stack-utils'

export interface StackFrame extends StackLineData {
line?: number
Expand All @@ -17,9 +17,9 @@ export interface StackFrame extends StackLineData {
}

export class StackTrace {
constructor(public readonly frames: StackFrame[]) {}
constructor(public readonly frames: Array<StackFrame>) {}

get topFrame() {
get topFrame(): StackFrame | undefined {
return this.frames.find((entry) => entry.file)
}
}
21 changes: 13 additions & 8 deletions packages/webpack-source-map/integration/resolve.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { SourceMap } from 'module'
import path from 'path'
import webpack from 'webpack'
import type { SourceMap } from 'module'

import { resolve } from '../src'
import { describe } from '@jest/globals'
import { beforeAll } from '@jest/globals'
import { it } from '@jest/globals'
import { expect } from '@jest/globals'
import path from 'path'
import webpack from 'webpack'

import { resolve } from '../src/index.js'

describe('resolve webpack source map', () => {
beforeAll(async () => {
Expand All @@ -20,19 +25,19 @@ describe('resolve webpack source map', () => {
},
})

// eslint-disable-next-line no-shadow
await new Promise((resolve, reject) => {
await new Promise((res, rej) => {
compiler.run((error) => {
if (error && !error.message) {
reject(error)
rej(error)
} else {
resolve(null)
res(null)
}
})
})
})

it('simple', () => {
// eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style
const sourceMap = resolve(
'webpack-internal:///./fixtures/simple.js',
path.join(__dirname, 'fixtures', 'dist', 'simple.js')
Expand Down
Loading