mirror of
https://github.com/denoland/deno.git
synced 2025-01-11 08:33:43 -05:00
fix(npm): handle more reserved words as cjs exports (#19672)
Closes #19665
This commit is contained in:
parent
bc381572d1
commit
3b9845d891
6 changed files with 259 additions and 16 deletions
|
@ -103,13 +103,13 @@ itest!(conditional_exports {
|
|||
});
|
||||
|
||||
itest!(conditional_exports_node_modules_dir {
|
||||
args:
|
||||
"run --allow-read --node-modules-dir $TESTDATA/npm/conditional_exports/main.js",
|
||||
output: "npm/conditional_exports/main_node_modules.out",
|
||||
envs: env_vars_for_npm_tests(),
|
||||
http_server: true,
|
||||
temp_cwd: true,
|
||||
});
|
||||
args:
|
||||
"run --allow-read --node-modules-dir $TESTDATA/npm/conditional_exports/main.js",
|
||||
output: "npm/conditional_exports/main_node_modules.out",
|
||||
envs: env_vars_for_npm_tests(),
|
||||
http_server: true,
|
||||
temp_cwd: true,
|
||||
});
|
||||
|
||||
itest!(dual_cjs_esm {
|
||||
args: "run -A --quiet npm/dual_cjs_esm/main.ts",
|
||||
|
@ -2021,3 +2021,10 @@ fn top_level_install_package_json_explicit_opt_in() {
|
|||
|
||||
assert!(node_modules_dir.join("@denotest").exists());
|
||||
}
|
||||
|
||||
itest!(reserved_word_exports {
|
||||
args: "run npm/reserved_word_exports/main.ts",
|
||||
output: "npm/reserved_word_exports/main.out",
|
||||
envs: env_vars_for_npm_tests(),
|
||||
http_server: true,
|
||||
});
|
||||
|
|
67
cli/tests/testdata/npm/registry/@denotest/reserved-word-exports/1.0.0/index.cjs
vendored
Normal file
67
cli/tests/testdata/npm/registry/@denotest/reserved-word-exports/1.0.0/index.cjs
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
exports["abstract"] = "abstract";
|
||||
exports["arguments"] = "arguments";
|
||||
exports["async"] = "async";
|
||||
exports["await"] = "await";
|
||||
exports["boolean"] = "boolean";
|
||||
exports["break"] = "break";
|
||||
exports["byte"] = "byte";
|
||||
exports["case"] = "case";
|
||||
exports["catch"] = "catch";
|
||||
exports["char"] = "char";
|
||||
exports["class"] = "class";
|
||||
exports["const"] = "const";
|
||||
exports["continue"] = "continue";
|
||||
exports["debugger"] = "debugger";
|
||||
exports["default"] = "default";
|
||||
exports["delete"] = "delete";
|
||||
exports["do"] = "do";
|
||||
exports["double"] = "double";
|
||||
exports["else"] = "else";
|
||||
exports["enum"] = "enum";
|
||||
exports["eval"] = "eval";
|
||||
exports["export"] = "export";
|
||||
exports["extends"] = "extends";
|
||||
exports["false"] = "false";
|
||||
exports["final"] = "final";
|
||||
exports["finally"] = "finally";
|
||||
exports["float"] = "float";
|
||||
exports["for"] = "for";
|
||||
exports["function"] = "function";
|
||||
exports["get"] = "get";
|
||||
exports["goto"] = "goto";
|
||||
exports["if"] = "if";
|
||||
exports["implements"] = "implements";
|
||||
exports["import"] = "import";
|
||||
exports["in"] = "in";
|
||||
exports["instanceof"] = "instanceof";
|
||||
exports["int"] = "int";
|
||||
exports["interface"] = "interface";
|
||||
exports["let"] = "let";
|
||||
exports["long"] = "long";
|
||||
exports["native"] = "native";
|
||||
exports["new"] = "new";
|
||||
exports["null"] = "null";
|
||||
exports["package"] = "package";
|
||||
exports["private"] = "private";
|
||||
exports["protected"] = "protected";
|
||||
exports["public"] = "public";
|
||||
exports["return"] = "return";
|
||||
exports["set"] = "set";
|
||||
exports["short"] = "short";
|
||||
exports["static"] = "static";
|
||||
exports["super"] = "super";
|
||||
exports["switch"] = "switch";
|
||||
exports["synchronized"] = "synchronized";
|
||||
exports["this"] = "this";
|
||||
exports["throw"] = "throw";
|
||||
exports["throws"] = "throws";
|
||||
exports["transient"] = "transient";
|
||||
exports["true"] = "true";
|
||||
exports["try"] = "try";
|
||||
exports["typeof"] = "typeof";
|
||||
exports["var"] = "var";
|
||||
exports["void"] = "void";
|
||||
exports["volatile"] = "volatile";
|
||||
exports["while"] = "while";
|
||||
exports["with"] = "with";
|
||||
exports["yield"] = "yield";
|
5
cli/tests/testdata/npm/registry/@denotest/reserved-word-exports/1.0.0/package.json
vendored
Normal file
5
cli/tests/testdata/npm/registry/@denotest/reserved-word-exports/1.0.0/package.json
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"name": "@denotest/reserved-word-exports",
|
||||
"version": "1.0.0",
|
||||
"main": "index.cjs"
|
||||
}
|
139
cli/tests/testdata/npm/reserved_word_exports/main.out
vendored
Normal file
139
cli/tests/testdata/npm/reserved_word_exports/main.out
vendored
Normal file
|
@ -0,0 +1,139 @@
|
|||
Download http://localhost:4545/npm/registry/@denotest/reserved-word-exports
|
||||
Download http://localhost:4545/npm/registry/@denotest/reserved-word-exports/1.0.0.tgz
|
||||
[Module: null prototype] {
|
||||
abstract: "abstract",
|
||||
arguments: "arguments",
|
||||
async: "async",
|
||||
await: "await",
|
||||
boolean: "boolean",
|
||||
break: "break",
|
||||
byte: "byte",
|
||||
case: "case",
|
||||
catch: "catch",
|
||||
char: "char",
|
||||
class: "class",
|
||||
const: "const",
|
||||
continue: "continue",
|
||||
debugger: "debugger",
|
||||
default: {
|
||||
abstract: "abstract",
|
||||
arguments: "arguments",
|
||||
async: "async",
|
||||
await: "await",
|
||||
boolean: "boolean",
|
||||
break: "break",
|
||||
byte: "byte",
|
||||
case: "case",
|
||||
catch: "catch",
|
||||
char: "char",
|
||||
class: "class",
|
||||
const: "const",
|
||||
continue: "continue",
|
||||
debugger: "debugger",
|
||||
default: "default",
|
||||
delete: "delete",
|
||||
do: "do",
|
||||
double: "double",
|
||||
else: "else",
|
||||
enum: "enum",
|
||||
eval: "eval",
|
||||
export: "export",
|
||||
extends: "extends",
|
||||
false: "false",
|
||||
final: "final",
|
||||
finally: "finally",
|
||||
float: "float",
|
||||
for: "for",
|
||||
function: "function",
|
||||
get: "get",
|
||||
goto: "goto",
|
||||
if: "if",
|
||||
implements: "implements",
|
||||
import: "import",
|
||||
in: "in",
|
||||
instanceof: "instanceof",
|
||||
int: "int",
|
||||
interface: "interface",
|
||||
let: "let",
|
||||
long: "long",
|
||||
native: "native",
|
||||
new: "new",
|
||||
null: "null",
|
||||
package: "package",
|
||||
private: "private",
|
||||
protected: "protected",
|
||||
public: "public",
|
||||
return: "return",
|
||||
set: "set",
|
||||
short: "short",
|
||||
static: "static",
|
||||
super: "super",
|
||||
switch: "switch",
|
||||
synchronized: "synchronized",
|
||||
this: "this",
|
||||
throw: "throw",
|
||||
throws: "throws",
|
||||
transient: "transient",
|
||||
true: "true",
|
||||
try: "try",
|
||||
typeof: "typeof",
|
||||
var: "var",
|
||||
void: "void",
|
||||
volatile: "volatile",
|
||||
while: "while",
|
||||
with: "with",
|
||||
yield: "yield"
|
||||
},
|
||||
delete: "delete",
|
||||
do: "do",
|
||||
double: "double",
|
||||
else: "else",
|
||||
enum: "enum",
|
||||
eval: "eval",
|
||||
export: "export",
|
||||
extends: "extends",
|
||||
false: "false",
|
||||
final: "final",
|
||||
finally: "finally",
|
||||
float: "float",
|
||||
for: "for",
|
||||
function: "function",
|
||||
get: "get",
|
||||
goto: "goto",
|
||||
if: "if",
|
||||
implements: "implements",
|
||||
import: "import",
|
||||
in: "in",
|
||||
instanceof: "instanceof",
|
||||
int: "int",
|
||||
interface: "interface",
|
||||
let: "let",
|
||||
long: "long",
|
||||
native: "native",
|
||||
new: "new",
|
||||
null: "null",
|
||||
package: "package",
|
||||
private: "private",
|
||||
protected: "protected",
|
||||
public: "public",
|
||||
return: "return",
|
||||
set: "set",
|
||||
short: "short",
|
||||
static: "static",
|
||||
super: "super",
|
||||
switch: "switch",
|
||||
synchronized: "synchronized",
|
||||
this: "this",
|
||||
throw: "throw",
|
||||
throws: "throws",
|
||||
transient: "transient",
|
||||
true: "true",
|
||||
try: "try",
|
||||
typeof: "typeof",
|
||||
var: "var",
|
||||
void: "void",
|
||||
volatile: "volatile",
|
||||
while: "while",
|
||||
with: "with",
|
||||
yield: "yield"
|
||||
}
|
3
cli/tests/testdata/npm/reserved_word_exports/main.ts
vendored
Normal file
3
cli/tests/testdata/npm/reserved_word_exports/main.ts
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
import * as exports from "npm:@denotest/reserved-word-exports";
|
||||
|
||||
console.log(exports);
|
|
@ -366,9 +366,16 @@ fn esm_code_from_top_level_decls(
|
|||
|
||||
static RESERVED_WORDS: Lazy<HashSet<&str>> = Lazy::new(|| {
|
||||
HashSet::from([
|
||||
"abstract",
|
||||
"arguments",
|
||||
"async",
|
||||
"await",
|
||||
"boolean",
|
||||
"break",
|
||||
"byte",
|
||||
"case",
|
||||
"catch",
|
||||
"char",
|
||||
"class",
|
||||
"const",
|
||||
"continue",
|
||||
|
@ -376,41 +383,56 @@ static RESERVED_WORDS: Lazy<HashSet<&str>> = Lazy::new(|| {
|
|||
"default",
|
||||
"delete",
|
||||
"do",
|
||||
"double",
|
||||
"else",
|
||||
"enum",
|
||||
"eval",
|
||||
"export",
|
||||
"extends",
|
||||
"false",
|
||||
"final",
|
||||
"finally",
|
||||
"float",
|
||||
"for",
|
||||
"function",
|
||||
"get",
|
||||
"goto",
|
||||
"if",
|
||||
"implements",
|
||||
"import",
|
||||
"in",
|
||||
"instanceof",
|
||||
"int",
|
||||
"interface",
|
||||
"let",
|
||||
"long",
|
||||
"native",
|
||||
"new",
|
||||
"null",
|
||||
"package",
|
||||
"private",
|
||||
"protected",
|
||||
"public",
|
||||
"return",
|
||||
"set",
|
||||
"short",
|
||||
"static",
|
||||
"super",
|
||||
"switch",
|
||||
"synchronized",
|
||||
"this",
|
||||
"throw",
|
||||
"throws",
|
||||
"transient",
|
||||
"true",
|
||||
"try",
|
||||
"typeof",
|
||||
"var",
|
||||
"void",
|
||||
"volatile",
|
||||
"while",
|
||||
"with",
|
||||
"yield",
|
||||
"let",
|
||||
"enum",
|
||||
"implements",
|
||||
"interface",
|
||||
"package",
|
||||
"private",
|
||||
"protected",
|
||||
"public",
|
||||
"static",
|
||||
])
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue