File tree Expand file tree Collapse file tree 8 files changed +171
-167
lines changed Expand file tree Collapse file tree 8 files changed +171
-167
lines changed Original file line number Diff line number Diff line change @@ -21,15 +21,20 @@ const command = getBuildCommand({
2121 target : 'node20' ,
2222 tsconfig : './tsconfig.json' ,
2323 plugins : [ {
24+ // If the given path resolves to something in the root of the repository
25+ // then replace the path and externalize the import instead
2426 name : 'Local Externalizer' ,
2527 setup ( { onResolve } ) {
2628 onResolve ( {
2729 filter : / ^ \. { 1 , 2 } ( \/ .+ ) ? /
2830 } , args => {
2931 const absolutePath = pathlib . resolve ( args . resolveDir , args . path ) ;
3032 const { dir, ext, base } = pathlib . parse ( absolutePath ) ;
33+ // evan claims that esbuild doesn't rewrite import attributes
34+ // but i can't get json imports to work properly
3135 if ( ext === '.json' || dir !== repoRoot ) return undefined ;
3236
37+ // The new import path should be relative to the bin/index.js file
3338 const newDirectory = pathlib . relative ( './bin' , repoRoot ) ;
3439 return {
3540 external : true ,
Original file line number Diff line number Diff line change 2424 "astring" : " ^1.8.6" ,
2525 "chalk" : " ^5.0.1" ,
2626 "commander" : " ^13.0.0" ,
27- "esbuild" : " ^0.25.5 " ,
27+ "esbuild" : " ^0.25.8 " ,
2828 "eslint" : " ^9.31.0" ,
2929 "jsonschema" : " ^1.5.0" ,
3030 "lodash" : " ^4.17.21" ,
Original file line number Diff line number Diff line change 1111 "dependencies" : {
1212 "chalk" : " ^5.0.1" ,
1313 "commander" : " ^13.0.0" ,
14- "esbuild" : " ^0.25.5 "
14+ "esbuild" : " ^0.25.8 "
1515 },
1616 "exports" : {
1717 "." : {
Original file line number Diff line number Diff line change 2626 "devDependencies" : {
2727 "@sourceacademy/lib-compiler" : " workspace:^" ,
2828 "@sourceacademy/modules-buildtools" : " workspace:^" ,
29- "@typescript-eslint/rule-tester" : " ^8.33.1" ,
3029 "typescript" : " ^5.8.2"
3130 },
3231 "scripts" : {
Original file line number Diff line number Diff line change 1+ import { RuleTester } from 'eslint' ;
2+ import tabType from '../tabType' ;
3+
4+ describe ( 'Test collateTypeImports' , ( ) => {
5+ const tester = new RuleTester ( ) ;
6+ tester . run (
7+ 'tab-type' ,
8+ tabType ,
9+ {
10+ valid : [ {
11+ code : `
12+ import { defineTab } from '@sourceacademy/modules-lib/tabs/utils';
13+ export default defineTab({})
14+ `
15+ } , {
16+ code : `
17+ import { defineTab as definer } from '@sourceacademy/modules-lib/tabs/utils';
18+ export default definer({})
19+ `
20+ } , { code : `
21+ import { stuff } from 'somewhere';
22+ import { defineTab as definer } from '@sourceacademy/modules-lib/tabs/utils';
23+ export default definer({ stuff })
24+ ` } ] ,
25+ invalid : [ {
26+ code : '' ,
27+ errors : 1
28+ } , {
29+ code : `
30+ import { stuff } from 'somwhere';
31+ export default 0;
32+ ` ,
33+ errors : 1
34+ } , {
35+ code : `
36+ import { defineTab } from '@sourceacademy/modules-lib/tabs/utils';
37+ export default 0;
38+ ` ,
39+ errors : 1
40+ } ]
41+ }
42+ ) ;
43+ } ) ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 6363 "@vitest/coverage-v8" : " ^3.2.3" ,
6464 "@vitest/eslint-plugin" : " ^1.3.4" ,
6565 "@yarnpkg/types" : " ^4.0.1" ,
66- "esbuild" : " ^0.25.5 " ,
66+ "esbuild" : " ^0.25.8 " ,
6767 "eslint" : " ^9.31.0" ,
6868 "eslint-plugin-import" : " ^2.32.0" ,
6969 "eslint-plugin-jsdoc" : " ^51.3.1" ,
You can’t perform that action at this time.
0 commit comments