File tree Expand file tree Collapse file tree
packages/typeless-sample-bot/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,7 +26,6 @@ import {
2626 waitForAllSamples ,
2727 fromArray ,
2828} from './samples.js' ;
29- import url from 'node:url' ;
3029
3130let returnValue = 0 ;
3231
Original file line number Diff line number Diff line change 1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15+ // Reference notes:
1516// https://lihautan.com/step-by-step-guide-for-writing-a-babel-transformation/
1617// https://lihautan.com/babel-ast-explorer/
1718// https://github.com/esamattis/babel-plugin-ts-optchain/blob/master/packages/babel-plugin-ts-optchain/src/plugin.ts
Original file line number Diff line number Diff line change @@ -80,10 +80,24 @@ export async function* filterByContents(
8080
8181// Instead of a babelrc, this is used so that we can get more control over
8282// the transform process.
83+ //
84+ // The heavy path manipulation is required here to work around a problem
85+ // with finding Babel plugins on the path when running the bot from
86+ // outside its own tree. Babel will attempt to resolve plugins to
87+ // the most proximate node_modules, which will be the package being
88+ // operated upon, not us.
8389const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
90+ const ptPath = path . join (
91+ __dirname ,
92+ '..' ,
93+ '..' ,
94+ 'node_modules' ,
95+ '@babel' ,
96+ 'preset-typescript'
97+ ) ;
8498const itrPath = path . join ( __dirname , 'import-to-require' ) ;
8599const babelConfig = {
86- presets : [ [ '@babel/preset-typescript' , { } ] ] ,
100+ presets : [ [ ptPath , { } ] ] ,
87101 plugins : [ [ itrPath ] ] ,
88102 parserOpts : { } as babel . ParserOptions ,
89103 generatorOpts : {
You can’t perform that action at this time.
0 commit comments