Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LlamaIndexTS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
run-llama
LlamaIndexTS
Commits
4d94f6e5
Unverified
Commit
4d94f6e5
authored
2 months ago
by
Alex Yang
Committed by
GitHub
2 months ago
Browse files
Options
Downloads
Patches
Plain Diff
test: smoke test with cjs/esm dual package (#1644)
parent
7bd5d934
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
e2e/.gitignore
+1
-0
1 addition, 0 deletions
e2e/.gitignore
e2e/node/smoke.e2e.ts
+86
-0
86 additions, 0 deletions
e2e/node/smoke.e2e.ts
with
87 additions
and
0 deletions
e2e/.gitignore
+
1
−
0
View file @
4d94f6e5
logs
.temp
This diff is collapsed.
Click to expand it.
e2e/node/smoke.e2e.ts
0 → 100644
+
86
−
0
View file @
4d94f6e5
import
{
execSync
}
from
"
node:child_process
"
;
import
{
mkdir
,
rm
,
writeFile
}
from
"
node:fs/promises
"
;
import
{
resolve
}
from
"
node:path
"
;
import
{
test
}
from
"
node:test
"
;
import
{
testRootDir
}
from
"
./utils.js
"
;
await
test
(
"
cjs/esm dual module check
"
,
async
(
t
)
=>
{
const
esmImports
=
`import fs from 'node:fs/promises'
import { Document, MetadataMode, VectorStoreIndex } from 'llamaindex'
import { OpenAIEmbedding } from '@llamaindex/openai'
import { Settings } from '@llamaindex/core/global'`
;
const
cjsRequire
=
`const fs = require('fs').promises
const { Document, MetadataMode, VectorStoreIndex } = require('llamaindex')
const { OpenAIEmbedding } = require('@llamaindex/openai')
const { Settings } = require('@llamaindex/core/global')`
;
const
mainCode
=
`
async function main() {
Settings.embedModel = new OpenAIEmbedding({
model: 'text-embedding-3-small',
apiKey: '
${
process
.
env
.
OPENAI_API_KEY
}
',
})
const model = Settings.embedModel
if (model == null) {
process.exit(-1)
}
}
main().catch(console.error)`
;
t
.
before
(
async
()
=>
{
await
mkdir
(
resolve
(
testRootDir
,
"
.temp
"
),
{
recursive
:
true
,
mode
:
0o755
,
});
});
t
.
after
(
async
()
=>
{
await
rm
(
resolve
(
testRootDir
,
"
.temp
"
),
{
recursive
:
true
,
force
:
true
,
});
});
await
t
.
test
(
"
cjs
"
,
async
()
=>
{
const
cjsCode
=
`
${
cjsRequire
}
\n
${
mainCode
}
`
;
const
filePath
=
resolve
(
testRootDir
,
"
.temp
"
,
`
${
crypto
.
randomUUID
()}
.cjs`
,
);
await
writeFile
(
filePath
,
cjsCode
,
"
utf-8
"
);
execSync
(
`
${
process
.
argv
[
0
]}
${
filePath
}
`
,
{
cwd
:
process
.
cwd
(),
});
});
await
t
.
test
(
"
esm
"
,
async
()
=>
{
const
esmCode
=
`
${
esmImports
}
\n
${
mainCode
}
`
;
const
filePath
=
resolve
(
testRootDir
,
"
.temp
"
,
`
${
crypto
.
randomUUID
()}
.mjs`
,
);
await
writeFile
(
filePath
,
esmCode
,
"
utf-8
"
);
execSync
(
`
${
process
.
argv
[
0
]}
${
filePath
}
`
,
{
cwd
:
process
.
cwd
(),
});
});
const
specialConditions
=
[
"
edge-light
"
,
"
workerd
"
,
"
react-server
"
];
for
(
const
condition
of
specialConditions
)
{
await
t
.
test
(
condition
,
async
()
=>
{
const
esmCode
=
`
${
esmImports
}
\n
${
mainCode
}
`
;
const
filePath
=
resolve
(
testRootDir
,
"
.temp
"
,
`
${
crypto
.
randomUUID
()}
.mjs`
,
);
await
writeFile
(
filePath
,
esmCode
,
"
utf-8
"
);
execSync
(
`
${
process
.
argv
[
0
]}
${
filePath
}
-C
${
condition
}
`
,
{
cwd
:
process
.
cwd
(),
});
});
}
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment