{"_id":"@fal-works/esbuild-plugin-global-externals","_rev":"3513119","name":"@fal-works/esbuild-plugin-global-externals","description":"esbuild plugin for replacing imports with global variables.","dist-tags":{"latest":"2.1.2"},"maintainers":[{"name":"fal-works","email":""}],"time":{"modified":"2024-08-27T20:32:07.000Z","created":"2021-01-24T14:16:46.971Z","2.1.2":"2021-07-19T14:57:01.362Z","2.1.1":"2021-02-04T05:17:26.850Z","2.1.0":"2021-02-04T04:58:38.085Z","2.0.0":"2021-02-03T13:05:13.914Z","1.2.0":"2021-02-03T08:52:56.826Z","1.1.0":"2021-02-02T01:14:28.618Z","1.0.0":"2021-01-28T14:12:42.417Z","0.1.0":"2021-01-24T14:16:46.971Z"},"users":{},"author":{"name":"FAL"},"versions":{"2.1.2":{"name":"@fal-works/esbuild-plugin-global-externals","description":"esbuild plugin for replacing imports with global variables.","version":"2.1.2","license":"MIT","author":{"name":"FAL"},"keywords":["esbuild"],"homepage":"https://github.com/fal-works/esbuild-plugin-global-externals#readme","bugs":{"url":"https://github.com/fal-works/esbuild-plugin-global-externals/issues"},"type":"module","main":"lib/index.cjs","module":"lib/index.js","exports":{"import":"./lib/index.js","require":"./lib/index.cjs"},"types":"lib/index.d.ts","directories":{"lib":"lib"},"devDependencies":{"@typescript-eslint/eslint-plugin":"4.28.3","@typescript-eslint/parser":"^4.28.3","esbuild":"^0.12.15","eslint":"7.31.0","eslint-config-prettier":"^8.3.0","eslint-plugin-total-functions":"^4.9.0","prettier":"^2.3.2","rimraf":"^3.0.2","typescript":"^4.3.5"},"scripts":{"prebuild":"rimraf lib","build":"npm run build:esm & npm run build:cjs","build:esm":"tsc && npm run format:lib:esm","preformat:lib:esm":"eslint --fix --no-ignore lib/**/*.{js,ts}","format:lib:esm":"prettier --write lib/**/*.{js,ts}","build:cjs":"esbuild src/index.ts --outfile=lib/index.cjs --format=cjs --platform=node --bundle --minify","lint":"eslint src/","test":"node test/test.js"},"gitHead":"5060147a2fbc8f9bea55085864c981469afaed2a","_id":"@fal-works/esbuild-plugin-global-externals@2.1.2","_nodeVersion":"14.17.3","_npmVersion":"6.14.13","dist":{"shasum":"c05ed35ad82df8e6ac616c68b92c2282bd083ba4","size":5756,"noattachment":false,"key":"/@fal-works/esbuild-plugin-global-externals/-/@fal-works/esbuild-plugin-global-externals-2.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/@fal-works/esbuild-plugin-global-externals/download/@fal-works/esbuild-plugin-global-externals-2.1.2.tgz"},"_npmUser":{"name":"fal-works","email":"falworks.contact@gmail.com"},"maintainers":[{"name":"fal-works","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/esbuild-plugin-global-externals_2.1.2_1626706621245_0.7878668364151904"},"_hasShrinkwrap":false,"publish_time":1626706621362,"_cnpm_publish_time":1626706621362,"_cnpmcore_publish_time":"2021-12-18T00:15:31.069Z"},"2.1.1":{"name":"@fal-works/esbuild-plugin-global-externals","description":"esbuild plugin for replacing imports with global variables.","version":"2.1.1","license":"MIT","author":{"name":"FAL"},"keywords":["esbuild"],"homepage":"https://github.com/fal-works/esbuild-plugin-global-externals#readme","bugs":{"url":"https://github.com/fal-works/esbuild-plugin-global-externals/issues"},"type":"module","main":"lib/index.cjs","module":"lib/index.js","exports":{"import":"./lib/index.js","require":"./lib/index.cjs"},"types":"lib/index.d.ts","directories":{"lib":"lib"},"dependencies":{"esbuild":"^0.8.40"},"devDependencies":{"@typescript-eslint/eslint-plugin":"4.14.2","@typescript-eslint/parser":"^4.14.2","eslint":"7.19.0","eslint-config-prettier":"^7.2.0","eslint-plugin-total-functions":"^4.7.2","prettier":"^2.2.1","rimraf":"^3.0.2","typescript":"^4.1.3"},"scripts":{"prebuild":"rimraf lib","build":"npm run build:esm & npm run build:cjs","build:esm":"tsc && npm run format:lib:esm","preformat:lib:esm":"eslint --fix --no-ignore lib/**/*.{js,ts}","format:lib:esm":"prettier --write lib/**/*.{js,ts}","build:cjs":"esbuild src/index.ts --outfile=lib/index.cjs --format=cjs --platform=node --bundle --minify","lint":"eslint src/","test":"node test/test.js"},"gitHead":"630c84ee2cd09e31e8b9c869640b9156bba258e8","_id":"@fal-works/esbuild-plugin-global-externals@2.1.1","_nodeVersion":"14.15.4","_npmVersion":"6.14.10","dist":{"shasum":"1cef79df7a897c98cdec9b8e72f89459c0f740e9","size":5687,"noattachment":false,"key":"/@fal-works/esbuild-plugin-global-externals/-/@fal-works/esbuild-plugin-global-externals-2.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/@fal-works/esbuild-plugin-global-externals/download/@fal-works/esbuild-plugin-global-externals-2.1.1.tgz"},"_npmUser":{"name":"fal-works","email":"falworks.contact@gmail.com"},"maintainers":[{"name":"fal-works","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/esbuild-plugin-global-externals_2.1.1_1612415846715_0.513090401210855"},"_hasShrinkwrap":false,"publish_time":1612415846850,"_cnpm_publish_time":1612415846850,"_cnpmcore_publish_time":"2021-12-18T00:15:31.419Z"},"2.1.0":{"name":"@fal-works/esbuild-plugin-global-externals","description":"esbuild plugin for replacing imports with global variables.","version":"2.1.0","license":"MIT","author":{"name":"FAL"},"keywords":["esbuild"],"homepage":"https://github.com/fal-works/esbuild-plugin-global-externals#readme","bugs":{"url":"https://github.com/fal-works/esbuild-plugin-global-externals/issues"},"main":"lib/index.cjs","module":"lib/index.js","exports":{"import":"./lib/index.js","require":"./lib/index.cjs"},"type":"module","directories":{"lib":"lib"},"dependencies":{"esbuild":"^0.8.40"},"devDependencies":{"@typescript-eslint/eslint-plugin":"4.14.2","@typescript-eslint/parser":"^4.14.2","eslint":"7.19.0","eslint-config-prettier":"^7.2.0","eslint-plugin-total-functions":"^4.7.2","prettier":"^2.2.1","rimraf":"^3.0.2","typescript":"^4.1.3"},"scripts":{"prebuild":"rimraf lib","build":"npm run build:esm & npm run build:cjs","build:esm":"tsc && npm run format:lib:esm","preformat:lib:esm":"eslint --fix --no-ignore lib/**/*.{js,ts}","format:lib:esm":"prettier --write lib/**/*.{js,ts}","build:cjs":"esbuild src/index.ts --outfile=lib/index.cjs --format=cjs --platform=node --bundle --minify","lint":"eslint src/","test":"node test/test.js"},"gitHead":"3b45a15c63a736197df78be47be77052d1a04fe2","_id":"@fal-works/esbuild-plugin-global-externals@2.1.0","_nodeVersion":"14.15.4","_npmVersion":"6.14.10","dist":{"shasum":"0bcb441c5dbea88175fdf9512bf7595cdf0a936e","size":5679,"noattachment":false,"key":"/@fal-works/esbuild-plugin-global-externals/-/@fal-works/esbuild-plugin-global-externals-2.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@fal-works/esbuild-plugin-global-externals/download/@fal-works/esbuild-plugin-global-externals-2.1.0.tgz"},"_npmUser":{"name":"fal-works","email":"falworks.contact@gmail.com"},"maintainers":[{"name":"fal-works","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/esbuild-plugin-global-externals_2.1.0_1612414717955_0.07640079652496601"},"_hasShrinkwrap":false,"publish_time":1612414718085,"_cnpm_publish_time":1612414718085,"_cnpmcore_publish_time":"2021-12-18T00:15:31.796Z"},"2.0.0":{"name":"@fal-works/esbuild-plugin-global-externals","description":"esbuild plugin for replacing imports with global variables.","version":"2.0.0","license":"MIT","author":{"name":"FAL"},"keywords":["esbuild"],"homepage":"https://github.com/fal-works/esbuild-plugin-global-externals#readme","bugs":{"url":"https://github.com/fal-works/esbuild-plugin-global-externals/issues"},"main":"lib/index.js","module":"lib/index.js","exports":"./lib/index.js","type":"module","directories":{"lib":"lib"},"dependencies":{"esbuild":"^0.8.39"},"devDependencies":{"@typescript-eslint/eslint-plugin":"4.14.2","@typescript-eslint/parser":"^4.14.2","eslint":"7.19.0","eslint-config-prettier":"^7.2.0","eslint-plugin-total-functions":"^4.7.2","prettier":"^2.2.1","rimraf":"^3.0.2","typescript":"^4.1.3"},"scripts":{"prebuild":"rimraf lib","build":"tsc && npm run format:lib","preformat:lib":"eslint --fix --no-ignore lib/**/*.{js,ts}","format:lib":"prettier --write lib/**/*.{js,ts}","lint":"eslint src/"},"gitHead":"750b4cfb01c250b2fbedb300890d802ac1617770","_id":"@fal-works/esbuild-plugin-global-externals@2.0.0","_nodeVersion":"14.15.4","_npmVersion":"6.14.10","dist":{"shasum":"6da65715977bd52bf91ab4f53fc323c51a6ced91","size":5139,"noattachment":false,"key":"/@fal-works/esbuild-plugin-global-externals/-/@fal-works/esbuild-plugin-global-externals-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@fal-works/esbuild-plugin-global-externals/download/@fal-works/esbuild-plugin-global-externals-2.0.0.tgz"},"_npmUser":{"name":"fal-works","email":"falworks.contact@gmail.com"},"maintainers":[{"name":"fal-works","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/esbuild-plugin-global-externals_2.0.0_1612357513772_0.5370065898278917"},"_hasShrinkwrap":false,"publish_time":1612357513914,"_cnpm_publish_time":1612357513914,"_cnpmcore_publish_time":"2021-12-18T00:15:32.143Z"},"1.2.0":{"name":"@fal-works/esbuild-plugin-global-externals","description":"esbuild plugin for replacing imports with global variables.","version":"1.2.0","license":"MIT","author":{"name":"FAL"},"keywords":["esbuild"],"homepage":"https://github.com/fal-works/esbuild-plugin-global-externals#readme","bugs":{"url":"https://github.com/fal-works/esbuild-plugin-global-externals/issues"},"main":"lib/index.js","module":"lib/index.js","exports":"./lib/index.js","type":"module","directories":{"lib":"lib"},"dependencies":{"esbuild":"^0.8.39"},"devDependencies":{"@typescript-eslint/eslint-plugin":"4.14.2","@typescript-eslint/parser":"^4.14.2","eslint":"7.19.0","eslint-config-prettier":"^7.2.0","eslint-plugin-total-functions":"^4.7.2","prettier":"^2.2.1","rimraf":"^3.0.2","typescript":"^4.1.3"},"scripts":{"prebuild":"rimraf lib","build":"tsc && npm run format:lib","preformat:lib":"eslint --fix --no-ignore lib/**/*.{js,ts}","format:lib":"prettier --write lib/**/*.{js,ts}","lint":"eslint src/"},"gitHead":"18537b2b2074d633f22d3c096ece74b9b54d5334","_id":"@fal-works/esbuild-plugin-global-externals@1.2.0","_nodeVersion":"14.15.4","_npmVersion":"6.14.10","dist":{"shasum":"61224e31e7e29f61603e985792058eeac50e89fe","size":4785,"noattachment":false,"key":"/@fal-works/esbuild-plugin-global-externals/-/@fal-works/esbuild-plugin-global-externals-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@fal-works/esbuild-plugin-global-externals/download/@fal-works/esbuild-plugin-global-externals-1.2.0.tgz"},"_npmUser":{"name":"fal-works","email":"falworks.contact@gmail.com"},"maintainers":[{"name":"fal-works","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/esbuild-plugin-global-externals_1.2.0_1612342376666_0.25858266774830185"},"_hasShrinkwrap":false,"publish_time":1612342376826,"_cnpm_publish_time":1612342376826,"_cnpmcore_publish_time":"2021-12-18T00:15:32.450Z"},"1.1.0":{"name":"@fal-works/esbuild-plugin-global-externals","description":"esbuild plugin for replacing imports with global variables.","version":"1.1.0","license":"MIT","author":{"name":"FAL"},"keywords":["esbuild"],"homepage":"https://github.com/fal-works/esbuild-plugin-global-externals#readme","bugs":{"url":"https://github.com/fal-works/esbuild-plugin-global-externals/issues"},"main":"lib/index.js","module":"lib/index.js","exports":"./lib/index.js","type":"module","directories":{"lib":"lib"},"dependencies":{"esbuild":"^0.8.36"},"devDependencies":{"@typescript-eslint/eslint-plugin":"4.14.1","@typescript-eslint/parser":"^4.14.1","eslint":"7.18.0","eslint-config-prettier":"^7.2.0","eslint-plugin-total-functions":"^4.7.2","prettier":"^2.2.1","rimraf":"^3.0.2","typescript":"^4.1.3"},"scripts":{"prebuild":"rimraf lib","build":"tsc && npm run format:lib","preformat:lib":"eslint --fix --no-ignore lib/**/*.{js,ts}","format:lib":"prettier --write lib/**/*.{js,ts}"},"gitHead":"44bad86be8beddc08255a135304f5bb7b4c2d6f1","_id":"@fal-works/esbuild-plugin-global-externals@1.1.0","_nodeVersion":"14.15.4","_npmVersion":"6.14.10","dist":{"shasum":"4a00c3ade1a4d352101b0370806c687fc64016eb","size":3570,"noattachment":false,"key":"/@fal-works/esbuild-plugin-global-externals/-/@fal-works/esbuild-plugin-global-externals-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@fal-works/esbuild-plugin-global-externals/download/@fal-works/esbuild-plugin-global-externals-1.1.0.tgz"},"_npmUser":{"name":"fal-works","email":"falworks.contact@gmail.com"},"maintainers":[{"name":"fal-works","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/esbuild-plugin-global-externals_1.1.0_1612228468483_0.10247093194391033"},"_hasShrinkwrap":false,"publish_time":1612228468618,"_cnpm_publish_time":1612228468618,"_cnpmcore_publish_time":"2021-12-18T00:15:32.794Z"},"1.0.0":{"name":"@fal-works/esbuild-plugin-global-externals","description":"esbuild plugin for replacing imports with global variables.","version":"1.0.0","license":"MIT","author":{"name":"FAL"},"keywords":["esbuild"],"homepage":"https://github.com/fal-works/esbuild-plugin-global-externals#readme","bugs":{"url":"https://github.com/fal-works/esbuild-plugin-global-externals/issues"},"main":"lib/index.js","module":"lib/index.js","exports":"./lib/index.js","type":"module","directories":{"lib":"lib"},"dependencies":{"esbuild":"^0.8.36"},"devDependencies":{"@typescript-eslint/eslint-plugin":"4.14.1","@typescript-eslint/parser":"^4.14.1","eslint":"7.18.0","eslint-config-prettier":"^7.2.0","prettier":"^2.2.1","rimraf":"^3.0.2","typescript":"^4.1.3"},"scripts":{"prebuild":"rimraf lib","build":"tsc && npm run format:lib","preformat:lib":"eslint --fix --no-ignore lib/**/*.{js,ts}","format:lib":"prettier --write lib/**/*.{js,ts}"},"gitHead":"b217e20b8a21161f5757a89b8bc59e2fa49d5777","_id":"@fal-works/esbuild-plugin-global-externals@1.0.0","_nodeVersion":"14.15.4","_npmVersion":"6.14.10","dist":{"shasum":"d40211b3c5185c902dd8e62d00160c66fa0fa8b0","size":2683,"noattachment":false,"key":"/@fal-works/esbuild-plugin-global-externals/-/@fal-works/esbuild-plugin-global-externals-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@fal-works/esbuild-plugin-global-externals/download/@fal-works/esbuild-plugin-global-externals-1.0.0.tgz"},"_npmUser":{"name":"fal-works","email":"falworks.contact@gmail.com"},"maintainers":[{"name":"fal-works","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/esbuild-plugin-global-externals_1.0.0_1611843162206_0.6410648721515002"},"_hasShrinkwrap":false,"publish_time":1611843162417,"_cnpm_publish_time":1611843162417,"_cnpmcore_publish_time":"2021-12-18T00:15:33.058Z"},"0.1.0":{"name":"@fal-works/esbuild-plugin-global-externals","description":"esbuild plugin for replacing imports with global variables.","version":"0.1.0","license":"MIT","author":{"name":"FAL"},"keywords":["esbuild"],"homepage":"https://github.com/fal-works/esbuild-plugin-global-externals#readme","bugs":{"url":"https://github.com/fal-works/esbuild-plugin-global-externals/issues"},"main":"lib/index.js","module":"lib/index.js","exports":"./lib/index.js","type":"module","directories":{"lib":"lib"},"dependencies":{"esbuild":"^0.8.34","fast-glob":"^3.2.5"},"devDependencies":{"@typescript-eslint/eslint-plugin":"4.14.0","@typescript-eslint/parser":"^4.14.0","eslint":"7.18.0","eslint-config-prettier":"^7.2.0","prettier":"^2.2.1","typescript":"^4.1.3"},"scripts":{"build":"tsc && npm run format:lib","preformat:lib":"eslint --fix --no-ignore lib/**/*.js","format:lib":"prettier --write lib/**/*.js"},"gitHead":"cdf90207375bead1cfb4af9a3de8fade2b225a1e","_id":"@fal-works/esbuild-plugin-global-externals@0.1.0","_nodeVersion":"14.15.4","_npmVersion":"6.14.10","dist":{"shasum":"6f3abb7fc29e75efe70ddbfa1370ff376fb50ad2","size":2215,"noattachment":false,"key":"/@fal-works/esbuild-plugin-global-externals/-/@fal-works/esbuild-plugin-global-externals-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@fal-works/esbuild-plugin-global-externals/download/@fal-works/esbuild-plugin-global-externals-0.1.0.tgz"},"_npmUser":{"name":"fal-works","email":"falworks.contact@gmail.com"},"maintainers":[{"name":"fal-works","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/esbuild-plugin-global-externals_0.1.0_1611497806829_0.5824475293938192"},"_hasShrinkwrap":false,"publish_time":1611497806971,"_cnpm_publish_time":1611497806971,"_cnpmcore_publish_time":"2021-12-18T00:15:33.254Z"}},"readme":"# esbuild-plugin-global-externals\n\n[esbuild](https://esbuild.github.io/) plugin for replacing imports with global variables.\n\nSimilar to (but not the same as) `output.globals` option of [Rollup](https://rollupjs.org/). See also: [evanw/esbuild#337](https://github.com/evanw/esbuild/issues/337)\n\nOriginally developed with esbuild v0.8.40, and should work with higher versions as well.\n\n\n## TL;DR\n\nThis:\n\n```js\nimport p5 from \"p5\";\nnew p5();\n```\n\ntranspiles to:\n\n```js\n// Here a variable `p5` should be defined globally (typically via UMD)\nvar p5_default = p5;\nnew p5_default();\n```\n\n\n## Usage example\n\n```js\nimport { globalExternals } from \"@fal-works/esbuild-plugin-global-externals\";\n\n/** Mapping from module paths to global variables */\nconst globals = {\n  jquery: \"$\"\n};\n\nesbuild.build({\n  entryPoints: [\"src/main.js\"],\n  outfile: \"dist/bundle.js\",\n  bundle: true,\n  plugins: [globalExternals(globals)],\n});\n```\n\nIf you prefer `RegExp` use `globalExternalsWithRegExp()` instead, however note that the `RegExp` you'll pass should be valid in Go language as well.\n\n\n## Configuration\n\nInstead of simply providing variable names only, you can pass `ModuleInfo` objects to configure the loading behavior for each module.\n\n### Module type\n\nEither `\"esm\"` (default) or `\"cjs\"`.\n\nThis determines the internal behavior of this plugin when loading modules (which affects the code after bundling as well).\n\n```js\nglobalExternals({\n  \"someModulePath\": {\n    varName: \"someGlobalVar\",\n    type: \"cjs\"\n  }\n})\n```\n\n### Named/default export\n\nIf `type: \"esm\"` and also if you're doing named import with some modules in question, you have to tell which variables from each module should be importable.\n\nAdditionally, if you don't do default import/export, you can prevent emitting code for this with `defaultExport: false`.\n\nBoth have no effects if `type: \"cjs\"` (which should work fine with named imports as well).\n\n```js\nglobalExternals({\n  \"someModulePath\": {\n    varName: \"someGlobalVar\",\n    namedExports: [\"someExportedVar\"],\n    defaultExport: false\n  }\n})\n```\n\nThe example above enables the following even if `type: \"esm\"`:\n\n```js\nimport { someExportedVar } from \"someModulePath\";\n```\n\nwhich transpiles to:\n\n```js\nvar someExportedVar = someGlobalVar.someExportedVar;\n```\n","_attachments":{},"homepage":"https://github.com/fal-works/esbuild-plugin-global-externals#readme","bugs":{"url":"https://github.com/fal-works/esbuild-plugin-global-externals/issues"},"license":"MIT"}