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 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
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.

17 changes: 9 additions & 8 deletions packages/stack-trace/integration/fixtures/simple.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
const repeat = require('repeat-string')

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

Check warning on line 2 in packages/stack-trace/integration/fixtures/simple.js

View workflow job for this annotation

GitHub Actions / Lint

(unknown): Unused eslint-disable directive (no problems were reported from '@typescript-eslint/no-require-imports' or '@typescript-eslint/no-var-requires').

Unused eslint-disable directive (no problems were reported from '@typescript-eslint/no-require-imports' or '@typescript-eslint/no-var-requires').
Raw output
> 1 | // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
    | ^
  2 | import repeat from 'repeat-string'
  3 |
  4 | export class Target {

export class Target {
static parseErrorStack() {
try {
return repeat({})
} catch (error) {
return parse(error.stack)
}
import('../../dist/parse.js').then((parse) => {
try {
return repeat({})
} catch (error) {
return parse(error.stack)
}
})
}
}
20 changes: 17 additions & 3 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 All @@ -12,7 +16,12 @@ describe('webpack stack trace', () => {
simple: path.join(__dirname, 'fixtures', 'simple.js'),
},
output: {
libraryTarget: 'commonjs',
library: {
type: 'module'
},
chunkFormat: 'module',
filename: 'simple.js',
libraryTarget: 'module',
path: path.join(__dirname, 'fixtures', 'dist'),
},
resolve: {
Expand All @@ -21,6 +30,9 @@ describe('webpack stack trace', () => {
module: {
rules: [{ test: /\.ts?$/, loader: 'ts-loader' }],
},
experiments: {
outputModule: true
}
})

await new Promise((resolve, reject) => {
Expand All @@ -37,8 +49,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
18 changes: 11 additions & 7 deletions packages/stack-trace/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"name": "@atls/stack-trace",
"version": "0.0.2",
"version": "0.0.3",
"license": "BSD-3-Clause",
"type": "module",
"main": "src/index.ts",
"exports": "./src/index.ts",
"files": [
"dist"
],
Expand All @@ -12,20 +14,22 @@
"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",
"main": "dist/index.js",
"exports": "./dist/index.js",
"typings": "dist/index.d.ts"
}
}
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'
4 changes: 2 additions & 2 deletions packages/stack-trace/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './stack-trace'
export * from './parse'
export * from './stack-trace.js'
export * from './parse.js'
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.js'

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.js'
import { isWebpackEnv } from './constants.js'
import { isProdEnv } from './constants.js'

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
Loading