From a72d786d6ae2cd0e4b0e9649e2c6af1f974e493a Mon Sep 17 00:00:00 2001 From: Pepijn Peeters Date: Sun, 5 Nov 2023 21:57:28 +0100 Subject: [PATCH] refactor(esm-shim): use prefix for build in module imports (#1622) * fix(esm-shim): use 'node:' prefix for build in module imports * fix(esm-shim): Update snapshots --- packages/esm-shim/src/constants.ts | 6 ++--- packages/esm-shim/test/snapshots/test.js.md | 24 +++++++++--------- packages/esm-shim/test/snapshots/test.js.snap | Bin 538 -> 540 bytes 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/esm-shim/src/constants.ts b/packages/esm-shim/src/constants.ts index 5ddd01ca6..ef2953f5e 100644 --- a/packages/esm-shim/src/constants.ts +++ b/packages/esm-shim/src/constants.ts @@ -2,9 +2,9 @@ export const CJSyntaxRegex = /__filename|__dirname|require\(|require\.resolve\(/ export const ESMShim = ` // -- Shims -- -import cjsUrl from 'url'; -import cjsPath from 'path'; -import cjsModule from 'module'; +import cjsUrl from 'node:url'; +import cjsPath from 'node:path'; +import cjsModule from 'node:module'; const __filename = cjsUrl.fileURLToPath(import.meta.url); const __dirname = cjsPath.dirname(__filename); const require = cjsModule.createRequire(import.meta.url); diff --git a/packages/esm-shim/test/snapshots/test.js.md b/packages/esm-shim/test/snapshots/test.js.md index e0176a0cb..1447dcc3a 100644 --- a/packages/esm-shim/test/snapshots/test.js.md +++ b/packages/esm-shim/test/snapshots/test.js.md @@ -10,9 +10,9 @@ Generated by [AVA](https://avajs.dev). `␊ // -- Shims --␊ - import cjsUrl from 'url';␊ - import cjsPath from 'path';␊ - import cjsModule from 'module';␊ + import cjsUrl from 'node:url';␊ + import cjsPath from 'node:path';␊ + import cjsModule from 'node:module';␊ const __filename = cjsUrl.fileURLToPath(import.meta.url);␊ const __dirname = cjsPath.dirname(__filename);␊ const require = cjsModule.createRequire(import.meta.url);␊ @@ -27,9 +27,9 @@ Generated by [AVA](https://avajs.dev). `␊ // -- Shims --␊ - import cjsUrl from 'url';␊ - import cjsPath from 'path';␊ - import cjsModule from 'module';␊ + import cjsUrl from 'node:url';␊ + import cjsPath from 'node:path';␊ + import cjsModule from 'node:module';␊ const __filename = cjsUrl.fileURLToPath(import.meta.url);␊ const __dirname = cjsPath.dirname(__filename);␊ const require = cjsModule.createRequire(import.meta.url);␊ @@ -58,9 +58,9 @@ Generated by [AVA](https://avajs.dev). ␊ ␊ // -- Shims --␊ - import cjsUrl from 'url';␊ - import cjsPath from 'path';␊ - import cjsModule from 'module';␊ + import cjsUrl from 'node:url';␊ + import cjsPath from 'node:path';␊ + import cjsModule from 'node:module';␊ const __filename = cjsUrl.fileURLToPath(import.meta.url);␊ const __dirname = cjsPath.dirname(__filename);␊ const require = cjsModule.createRequire(import.meta.url);␊ @@ -80,9 +80,9 @@ Generated by [AVA](https://avajs.dev). ␊ ␊ // -- Shims --␊ - import cjsUrl from 'url';␊ - import cjsPath from 'path';␊ - import cjsModule from 'module';␊ + import cjsUrl from 'node:url';␊ + import cjsPath from 'node:path';␊ + import cjsModule from 'node:module';␊ const __filename = cjsUrl.fileURLToPath(import.meta.url);␊ const __dirname = cjsPath.dirname(__filename);␊ const require = cjsModule.createRequire(import.meta.url);␊ diff --git a/packages/esm-shim/test/snapshots/test.js.snap b/packages/esm-shim/test/snapshots/test.js.snap index 5143ca0dc03c6ea36f374daf0e044269d9c0dabe..7c8a3ca3d7b213043a7090bfdce2b3e22540253f 100644 GIT binary patch literal 540 zcmV+%0^|KbRzVc63de9nQwl-&wDlhQW$ZLzplYcU%=%{ zsn0-oCeD!IQYtn#jsYrWN^eUqQFDt+R0Mr=4_ zQwm0U=}Tpes}jy!!RF2=mTHs3o6;5OLBoB-{j%w|^xXnXOkNhygs93wAYn9mc6vIO z1!%5-jbp(qSZ2o`KAMnzuuhgK@I0gXuj|NMx;ijmvuGLASs&mIzLwHO@Vc!`IN%s=AI_Pgm8UC3Rb|GnVXi6tQaofSs_ZCOzJC6Px zN2AeRT>XSwEA@f~8B@iKZX)A>!&lmP*2QD^c;x3gnKgM!4$~5Wp?6Yv+UK_2Vzz-) z&stXFZDhq6(ojTcdPbWz%;@EeY+nRCEs&6y?@C2mk==eg<*? literal 538 zcmV+#0_FWdRzVIQrP6F}J(HlBEzy;zz;Fjki*R$B=N$Q$*rCMa!V6`V{Wv_fq*7yjoEvyyPfPR-R`Y ziKQxX%8L~SX=O;s-%)FcVfc3n>{8LZz?NP}&0PnSix!lxTPXhkWi)yd zXFcK0DYKxBjHzQrH%l+30Az ziHp@-$_iF@P!gnTDDo#nh2I5RHm?#tpGO_;3@#fY2@Yl zWCv-7Ko2N#?Z@$c6X3cmP`M7^&_Vp6Mf|=dPVK`wIVG{{h{4!gz7_t5L))<0O5?vt cBj$&mHJfbu;kc!lgO+R_0Ti5Ov;PMG09DEicK`qY