Skip to content

Commit

Permalink
fix: remove createRequire code to generate commonjs (#843)
Browse files Browse the repository at this point in the history
* closed #840
* closed #842
  • Loading branch information
3846masa committed Apr 4, 2024
1 parent 266745f commit 5a32bf1
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 4 deletions.
5 changes: 4 additions & 1 deletion .babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ module.exports = (api) => {
const isTest = api.env('test');

return {
plugins: ['@babel/plugin-proposal-explicit-resource-management'],
plugins: [
'@babel/plugin-proposal-explicit-resource-management',
...(isTest ? [] : ['module:@reactioncommerce/babel-remove-es-create-require']),
],
presets: [
[
'@babel/preset-env',
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"@babel/preset-typescript": "7.24.1",
"@hapi/wreck": "18.0.1",
"@jest/globals": "29.7.0",
"@reactioncommerce/babel-remove-es-create-require": "1.0.0",
"@semantic-release/changelog": "6.0.3",
"@semantic-release/git": "10.0.1",
"@types/deasync": "0.1.5",
Expand Down
11 changes: 11 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/utils/create_cookie_header_value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Cookie } from 'tough-cookie';

import type { CookieOptions } from '../cookie_options';

const require = 'require' in globalThis ? globalThis.require : createRequire(import.meta.url);
const require = createRequire(import.meta.url);

type Params = {
cookieOptions: CookieOptions;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/save_cookies_from_header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createRequire } from 'node:module';

import type { CookieOptions } from '../cookie_options';

const require = 'require' in globalThis ? globalThis.require : createRequire(import.meta.url);
const require = createRequire(import.meta.url);

type Params = {
cookieOptions: CookieOptions;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/validate_cookie_options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createRequire } from 'node:module';

import type { CookieOptions } from '../cookie_options';

const require = 'require' in globalThis ? globalThis.require : createRequire(import.meta.url);
const require = createRequire(import.meta.url);

type ModuleResolver = (id: string) => string;

Expand Down

0 comments on commit 5a32bf1

Please sign in to comment.